LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

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

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

Rep: Reputation: 40
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, 07:45 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

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


Reply


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 05:26 AM
remote command execute telnet with 1 command MPowers Linux - Networking 2 06-30-2005 06:31 AM
command execute without ./ kaon Slackware 11 09-15-2004 05:14 PM
Execute a command as another user mpgram Linux - Newbie 6 06-08-2004 11:45 PM
Execute Command lawrencegoodman Linux - Newbie 2 10-23-2003 08:36 AM


All times are GMT -5. The time now is 04:31 AM.

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