How can i assign the ouput from system("ping myIP") to a variable on the linux platform. Im actually using a program called ding which prints an integer to the consoe. I need to redirect the output from the console to the variable.
Printable View
How can i assign the ouput from system("ping myIP") to a variable on the linux platform. Im actually using a program called ding which prints an integer to the consoe. I need to redirect the output from the console to the variable.
popen() is probably the easiest thing to use
Thanks I think ive got it working with.
Thanks againCode:FILE *fp;
char line[10];
fp = popen("ding -s -r 202.......", "r");
while ( fgets( line, sizeof line, fp))
{
cout << "result is " << line << endl;
}
pclose(fp);