I want to fetch the output of a shell execution in an ifstream
but the problem is that the program is never terminated, so I can't use popen()
. I have to fetch the output of various tools, but one example is ping
. So I either have to stop the program running in the pipe somehow so that popen()
returns the string or have some method (I don't know yet) to stream the output. I know I could use system()
, direct the output to a file and stream it in. But I would definitely prefer some direct method if there's any.
Does somebody know of a method to stream a Linux shell output of a self-invoked running program into an ifstream
or something similar?