I want to get a Linux command's output string as well as command output status in a C++ program. I am executing Linux commands in my application.
for example: Command:
rmdir abcd
Command output string:
rmdir: failed to remove `abcd': No such file or directory
Command Status:
1 (Which means command has been failed)
I tried using Linux function system()
which gives the output status, and function popen()
which gives me output string of a command, but neither function gives me both
the output string and output status of a Linux command.