LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Executing a shell script command!! (http://www.linuxquestions.org/questions/programming-9/executing-a-shell-script-command-353229/)

vishamr2000 08-14-2005 04:06 PM

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

trickykid 08-14-2005 05:23 PM

Moved: More suitable in our Programming forum, where programming questions belong.

leonscape 08-14-2005 05:32 PM

Yes you do what you want. See the System Function.

For more details and for control see Processes.

microsoft/linux 08-14-2005 09:11 PM

yep it just
[quote]
#include <stdio.h>

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

vishamr2000 08-15-2005 12:33 AM

Thx!!
 
Hi to all,

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

Warm regards,
Visham


All times are GMT -5. The time now is 06:34 AM.