View Full Version : Help in System()

Baraa Mahrouka
March 16th, 2010, 11:42 PM

as we all know the system command in C returns and integer,
I'm just trying to get the result of the system command as a string,
this command:
system("ifconfig -s | grep eth | awk {'$12'});
gives me the status of eth0 if its BMRU or BMU so I want to take this result (BMRU or BMU)
as a string ...

any help ?

March 17th, 2010, 12:13 AM
Instead of use system() try with popen().
See this (http://www-user.tu-chemnitz.de/~anhe/DOCU/C/C/////////FUNCTIONS/popen.html).

March 21st, 2010, 02:17 AM
or even:

system("ifconfig -s | grep eth | awk {'$12'} > /tmp/nettest.tmp");
then read /tmp/nettest.tmp