How to provide Shell Escape from a C program?

Rudrakshala Purushotham rudrak at saphir.cl.bull.fr
Tue Nov 20 00:30:36 AEST 1990


I want to provide shell escape feature from a C program. But I am having 
some problems with the following code:

	shell_escape (command);
	char *command;
	{
		...
		char *args [MAX_ARGS];

		args [0] = "/bin/sh";
		args [1] = "-c";

		for (i = 2; i < MAX_ARGS && (s = strtok (command, " \t")); i++)
			args [i] = strsave (s);
		
		args [i] = NULL;

		if (fork () > 0)	{
			execv ("/bin/sh", args);
			perror ("execv");
			_exit (1);
		}

		wait (&status);
		...

I am using C shell and System V. I tried `/bin/ls -l -R' as input to
shell_escape (), my .login file gets executed here and /bin/ls is executed
(without -l -R) options. 

Can some body help me with this problem? 

Thanks

-- Purushotham 
-- 
R. Purushotham                          Email: rudrak at saphir.cl.bull.fr
F7 1 D5 BULL SA                         Tel Off: 34627000 ext 3928
78340 Les Clayes sous Bois  FRANCE      Tel Res: 34604752
=======================================================================



More information about the Comp.unix.programmer mailing list