Here is a sample of
popen
that works, and demonstrates that the output can be more than a single line.
#include <stdio.h>
#include <stdlib.h>
int main(
)
{
char buffer[160];
FILE *foo;
foo = popen("ls -l", "r");
while (fgets(buffer, 160, foo) != NULL)
{
printf("%s", buffer);
}
pclose(foo);
printf("End of stream encountered\n");
return 0;
}
You need to check (by running at the terminal) that the command you are using produces actual output.
BTW re your comment "I am not allowed to ask Qt questions", this is not true, and no one has told you that. All that we have said is that you should not post Qt questions in the C/C++ forum. If you post them here in Quick Answers then people will (possibly) answer them. Also, this question is not a Qt specific onem as it is actually about getting the output of a command in Linux. The suggestion from k5054 to use popen is not specific to Qt.