catching output and errors with popen c++
I have code which at the moment only catches the command/program output if the program runs correctly, which is a small problem as I would like to capture everything from stdout inclusive of errors
FILE *fp;
fp = popen(command.c_str(), "r");
while(fgets(cbuf, 1024, fp) != NULL){
.....do stuff here....
}
pclose(fp);
Can anyone tell me where I am going wrong here ?
(Code is being compiled on ubuntu and debian)
Regards
Michael
|