Here is what I get from 'man execl':

int execl( const char *path, const char *arg, ...);

       The const char *arg and subsequent ellipses in the  execl,
       execlp,  and  execle  functions can be thought of as arg0,
       arg1, ..., argn.  Together they describe a list of one  or
       more  pointers  to  null-terminated strings that represent
       the argument list available to the executed program.   The
       first  argument,  by  convention, should point to the file
       name associated with the file being executed.  The list of
       arguments must be terminated by a NULL pointer.

It looks to me like the second example you give matches the man page,
while the first example is trying to use /bin/sh as the first argument
to the shell /bin/sh, which is wrong.

"Mike A. Harris" wrote:       
> 
> For the life of me I can't get a shellscript to run from
> execl() properly.  It is incredibly odd.
> 
> The script "test.sh" is an ordinary shell script with permissions
> set to 755 owned by root:root in /usr/local/bin and is in the
> path for everyone.
> 
> Inside an app I'm working on, I do a fork(), and then try to
> execl() the shellscript with:
> 
> execl("/bin/sh", "/bin/sh", "-c", "test.sh", NULL);
> 
> The above fails all the time period.
> 
> If I'm logged in as "mharris", and I do:
> 
> execl("/bin/sh", "-c", "test.sh", NULL);
> 
> It works, despite the documentation for execl saying the first
> two passed args should be the same.  If I log in as
> "testuser" however, and run the program it does not
> work.  Doesn't matter which of the above execl()'s I use.
> 
> I haven't used exec family of functions in programming much other
> than to fire off an executable here and there.  This is my first
> time wanting to fire off a shell script.  I've followed the
> manpage and GNU info documentation for exec family of functions
> and all to no avail.
> 
> Could someone please send me code which is guaranteed to execute
> ANY shell script regardless of what it is written in?  Or any
> other pointers would be appreciated as well.
> 
> Thanks.
> TTYL
> 
> --
> Mike A. Harris                                     Linux advocate
> Computer Consultant                                  GNU advocate
> Capslock Consulting                          Open Source advocate
> 
> Want to run Microsoft Windows software in Linux?  You can!  VMware allows
> you to install and run other operating systems inside a window in X windows.
> You can install Windows 95/98/NT/2000, FreeBSD, Solaris, and many more.
> 3D Games do not work yet, but virtually all office and productivity software
> runs excellent.           http://www.vmware.com
> 
> _______________________________________________
> Redhat-devel-list mailing list
> [EMAIL PROTECTED]
> https://listman.redhat.com/mailman/listinfo/redhat-devel-list



_______________________________________________
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

Reply via email to