LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   execute system command from c (http://www.linuxquestions.org/questions/programming-9/execute-system-command-from-c-344534/)

alaios 07-19-2005 02:06 AM

execute system command from c
 
Hi i need to execute in system command in c .... The previous days i had succesfully used the execl so as to remove a file from the system execl("rm,"rm","-l","my file"); and has worked fine;

Now i want to execute sth more difficult and i think i need your help
i want to execute the following
tc -s class show dev eth0
HELP

taylor_venable 07-19-2005 07:02 AM

Fork-Exec Or System(3)
 
I don't think that this is really any different from any other command issued from a C program; if you need to grab the output into a pipe or something you can fork and exec, or if you just need the output to show up on the terminal you could use a call to system(3).

Hko 07-19-2005 07:45 AM

Quote:

if you need to grab the output into a pipe or something you can fork and exec
I'd recommend "popen()" for capturing the output from a pipe. Much easier.
See "man 3 popen".


All times are GMT -5. The time now is 12:56 AM.