how do I exec() a script

Leo de Wit leo at ehviea.ine.philips.nl
Thu Jun 28 17:59:06 AEST 1990


In article <661 at kps.UUCP> llj at kps.se (Leif Ljung /DP) writes:
|I have a program that I want to do a general exec(2) sometimes
|executing a binary program, sometimes a shell-script preferably
|using PATH.
|Say I have the program `prog' - if this is a script I add the
|'#! /bin/sh' at the top. Can I exec(2) that? No.

Yes you can.

|
|The only way I have been able to exec the script is by executing
|a one-liner containing  `#! /bin/sh /path/prog.  '
|
|But this is not what I want. Not only is the first line limited in 
|length - 32 chars according to exec(2) - it also requires a secondary 
|file that I do not want, I just want to feed the script itself into 
|/bin/sh using the exec(). Is there a way to do this?
|
|The system is a Pyramid running BSD4.3.
|Any clues?

Yes, assuming you got the semantics of the exec(2) functions/syscalls
correct, you probably forgot to make the script executable. If not,
show us what your exec() call looks like.

Another hint: put a perror("This is what went wrong"); after the exec()
call. 9 out of 10 times you will see the problem immediately.

    Leo.



More information about the Comp.lang.c mailing list