Reputation: 14869
I would like my program to read the standard output produced by another application. I am aware that I can use popen
to do that and use fread
to read that output.
Do you know whether is possible to use read
(and possibly open
)? I am working in LINUX with C/C++
Upvotes: 0
Views: 339
Reputation: 9904
You can get a file descriptor for read()
by calling int fd = fileno(fp)
for the FILE *fp
you have got from popen()
. But be aware that you must not mix calling read()
and fread()
!
EDIT
If you want to avoid popen()
, you have to use pipe()
, fork()
, exec..()
and dup2()
like it's done here
Upvotes: 2