Is there a easier way to read the output of a Linux Shell Command like
ifconfig | grep "inet Adresse" | grep -v 127.0.0.1 | awk '{print $2}' | awk -F":" '{print $2}'
than using popen()
fp = popen(command, "r");
while(fgets(line, PATH_MAX, fp)!=NULL)
{
//someoperations
}
pclose(fp);
I need to get my info twice before and after some operations.
As my output is just one Line ?
I have used popen()
now, was the easiest way Thank you @pce
fp = popen(fullCommand, "r");
while(fgets(line, PATH_MAX, fp) != NULL);
pclose(fp);
line was type of
char line[PATH_MAX];
Thank all of you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.