LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 08-14-2005, 05:06 PM   #1
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Rep: Reputation: 31
Executing a shell script command!!


Hi to all,

I would like to know how to execute a shell script command in a C program. Let's say the program is as follows:

#include <stdio.h>

void main()
{
.
.
.
iptables -F
iptables -X
.
.
.
}

IS this possible? If not, how do i run a shell script from a C program?

Warm regards,
Visham
 
Old 08-14-2005, 06:23 PM   #2
trickykid
Guru
 
Registered: Jan 2001
Posts: 24,133

Rep: Reputation: 199Reputation: 199
Moved: More suitable in our Programming forum, where programming questions belong.
 
Old 08-14-2005, 06:32 PM   #3
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 47
Yes you do what you want. See the System Function.

For more details and for control see Processes.

Last edited by leonscape; 08-14-2005 at 06:33 PM.
 
Old 08-14-2005, 10:11 PM   #4
microsoft/linux
Senior Member
 
Registered: May 2004
Location: Sebec, ME, USA
Distribution: Debian Etch, Windows XP Home, FreeBSD
Posts: 1,445
Blog Entries: 9

Rep: Reputation: 45
yep it just
[quote]
#include <stdio.h>

void main()
{
.
.
.
system("iptables -F")
system("iptables -X")
.
.
.
}
 
Old 08-15-2005, 01:33 AM   #5
vishamr2000
Member
 
Registered: Aug 2004
Posts: 210

Original Poster
Rep: Reputation: 31
Thx!!

Hi to all,

Many many thx to microsoft/linux and leonscape...

Warm regards,
Visham
 
  


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
Problem executing mv command inside shell script pablogosse Linux - General 7 12-16-2009 01:21 PM
executing konsole from shell script Meriadoc Linux - Newbie 10 07-10-2009 09:08 AM
verify if the same shell script is executing in background hicham007 Programming 2 08-07-2005 06:40 AM
executing shell script on apache nooodles Linux - General 1 06-29-2004 02:51 AM
executing a shell script from C llama_meme Programming 2 04-01-2002 10:10 PM


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

Main Menu
Advertisement
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