Path: utzoo!attcan!uunet!ogicse!mintaka!bloom-beacon!eru!luth!sunic!mcsun!hp4nl!phigate!ehviea!leo From: leo@ehviea.ine.philips.nl (Leo de Wit) Newsgroups: comp.lang.c Subject: Re: how do I exec() a script Message-ID: <810@ehviea.ine.philips.nl> Date: 28 Jun 90 07:59:06 GMT References: <661@kps.UUCP> Reply-To: leo@ehviea.UUCP (Leo de Wit) Organization: Philips I&E Eindhoven Lines: 29 In article <661@kps.UUCP> llj@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.