Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcvax!hp4nl!botter!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.unix.wizards Subject: Re: exec() with executable shell scripts Keywords: exec() sh Message-ID: <2351@solo11.cs.vu.nl> Date: 22 Apr 89 03:04:54 GMT References: <647@mqcomp.oz> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 28 martin@mqcomp.oz (Martin Foord) writes: \Everytime I seem to exec() a shell script that is executable I have problems \(execepting if I use execlp() or execvp()). The shell script doesn't start with the magic number #! or your kernel doesn't recognize it, hence you get ENOEXEC ("Exec format error"), as you would have known, had you put a call to perror() in your C program. On the other hand, after having received an exec format error EXECVP() decides the file must be a shell script, and executes /bin/sh with the file as first argument. Hence execvp() works. \... \ execv("/bin/true",args); \ printf("Can't execute process\n"); Thanks a lot for that *VERY* helpful error message! :-( Instead do: perror("/bin/true"); If you are a Real Programmer, add: *(char *) -1 = 0xDEAD; and read the hexdump with breakfast! :-) -- "If it isn't aesthetically pleasing, |Maarten Litmaath @ VU Amsterdam: it's probably wrong." (jim@bilpin). |maart@cs.vu.nl, mcvax!botter!maart