cpp-subprocess icon indicating copy to clipboard operation
cpp-subprocess copied to clipboard

How to access/print a command response with multiple lines?

Open alexe100 opened this issue 6 years ago • 2 comments

I am executing a ps command and multiple lines are return. Why I am just see the first one? ... auto res = cut.communicate().first; std::cout << res.buf.data() << std::endl;

Please, how to iterate the res variable?

Thanks

alexe100 avatar Feb 19 '19 18:02 alexe100

Sorry, I did not see this. Will get back to you by EOD today.

arun11299 avatar Feb 25 '19 06:02 arun11299

I am running this in my Mac:

auto p = Popen({"ps"}, output{PIPE});
auto obuf = p.communicate().first;
std::cout << "Data : " << obuf.buf.data() << std::endl;

It gives me the entire output.

Can you please tell about the details of your platform and share the entire code ?

arun11299 avatar Feb 25 '19 18:02 arun11299