How do I execute a command and get output of command within C++ using POSIX?
I am looking for a way to get the output of a command when it is run from within a C++ program. I have looked at using the system() function, but that will just execute a command. Here's an example of what I'm looking for:
std::string result = system("./some_command");
I need to run an arbitrary command and get its output. I've looked at Boost.org, but I have not found anything that will give me what I need.
I believe what you are describing would require you to fork and then exec command that you want, and you can capture the information in that way using pipes or some other method.