Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!novavax!infocenter!mhoffman From: mhoffman@infocenter.UUCP (Mike Hoffman) Newsgroups: comp.unix.wizards Subject: Re: exec() with executable shell scripts Message-ID: <2154@infocenter.UUCP> Date: 27 Apr 89 20:44:23 GMT References: <2351@solo11.cs.vu.nl> Organization: Gould CSD, Fort Lauderdale, FL Lines: 33 in article <2351@solo11.cs.vu.nl>, maart@cs.vu.nl (Maarten Litmaath) says: > > 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 > ... > \... > \ execv("/bin/true",args); > \ printf("Can't execute process\n"); > How about: args[0] = "sh"; args[1] = "/bin/true"; args[2] = NULL; execv("/bin/sh",args); for files that do not begin with #! and are perhaps write-protected? Maybe the shell script is owned by root but the applications programmer doesn't have su priveleges. (Shame on the sysadm for writing shell scripts that don't start with #! :-) Michael J. Hoffman Voice: (407)255-8116 Manufacturing Engineering FAX: (407)255-8186 Encore Computer Corporation Email: mhoffman USnail: 100 N. Babcock St. UUCP: {uunet,codas!novavax,sun,pur-ee}!gould!mhoffman Melbourne, Fl 32935 "Curiouser and Curiouser" -- Alice