I may have found an example:
#include <stdio.h>
main()
{
FILE *fp;
char line[130];/* line of data from unix command*/
fp = popen("ls -l", "r");/* Issue the command.*/
/* Read a line*/
while ( fgets( line, sizeof line, fp))
{
printf("%s", line);
}
pclose(fp);
}
----
can you provide a short code example of popen(); storing the stdout value of "ls -la" or "netstat" into a char* type or string variable?
thankyou for your help
how do I store stdout value from system(); into a char* variable?
e.g.
I have child process that executes system(); function, but the output is displayed on server binary tty,
I would like to store the output of system("ls -la");
into a char* variable for later use / display .
is this...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.