Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 07-19-2005, 03:06 AM   #1
Senior Member
Registered: Jan 2003
Location: Aachen
Distribution: Opensuse 11.2 (nice and steady)
Posts: 2,203

Rep: Reputation: 45
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
Old 07-19-2005, 08:02 AM   #2
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
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).
Old 07-19-2005, 08:45 AM   #3
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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".


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
execute system command in c alaios Programming 3 07-13-2005 06:26 AM
remote command execute telnet with 1 command MPowers Linux - Networking 2 06-30-2005 07:31 AM
command execute without ./ kaon Slackware 11 09-15-2004 06:14 PM
Execute a command as another user mpgram Linux - Newbie 6 06-09-2004 12:45 AM
Execute Command lawrencegoodman Linux - Newbie 2 10-23-2003 09:36 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:35 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration