exec() with executable shell scripts

Mike Hoffman mhoffman at infocenter.UUCP
Fri Apr 28 06:44:23 AEST 1989


in article <2351 at solo11.cs.vu.nl>, maart at cs.vu.nl (Maarten Litmaath) says:
> 
> martin at 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



More information about the Comp.unix.wizards mailing list