Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!auspex!guy From: guy@auspex.auspex.com (Guy Harris) Newsgroups: comp.unix.programmer Subject: Re: How to provide Shell Escape from a C program? Message-ID: <4521@auspex.auspex.com> Date: 23 Nov 90 23:24:38 GMT References: <349@clbull.cl.bull.fr> <1990Nov20.150635.22378@ssd.kodak.com> Organization: Auspex Systems, Santa Clara Lines: 13 >>Can some body help me with this problem? > >From the man page for strtok: That's certainly *A* problem with his code, but far from the most fundamental one, and not the one that's screwing him up. The problem that's screwing him up, as others have noted, is that the "-c" flag to the shell takes *one* argument, which is a character string containing the command to be executed, in its entirety; his use of "strtok()" to try to carve the command up into tokens, and pass each token as an individual argument to the shell, is incorrect - and would still be incorrect even if he were correctly calling "strtok()" with a NULL pointer as the first argument in all but the first call.