[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: can i execute a shell script thro C program
On Sat, Apr 07, 2001 at 05:41:30PM +0530, manish k arya wrote:
>hi
> can u tell me that is it possible to execute a shell script through a C program .
>
>manish
Its very easy I wonder Y u even ask
this is the code that will do the trick
---------------------------------
#include<stdio.h>
int main (int argc, char *argv[])
{
if (fork() == 0)
execl( argv[1],0); // argv[1] can be a elf or
// a shell script won't
// matter just need to be
// chmoded to +x .
wait((int *)0);
printf("/n done");
}
--------------------------------
--
X windows: A mistake carried out to perfection.
................................
Pankaj Kaushal <pankaj@xxxxxxx>
Proud to use GNU <www.gnu.org>
#include<stdio.h>
int main (int argc, char *argv[])
{
if (fork() == 0)
execl( argv[1],0);
wait((int *)0);
printf("/n done");
}