What is a good way to do general execs?

Greg Limes limes at ouroborous.Sun.COM
Sat Jun 9 04:36:13 AEST 1990


In article <438 at mtndew.UUCP> friedl at mtndew.UUCP (Stephen J. Friedl) writes:
>	i = 0;
>	argv[i++] = "/bin/sh";
>	argv[i++] = userprog;
>
>	execv(argv[1], argv+1);
>	execv(argv[0], argv+0);
>	error("cannot run userprog %s (errno = %d)", userprog, errno);

what if "userprog" is a CSH script, or a PERL script, or an AWK
script, or ... [you get the idea]

Of course, if your system does not support scripts for anything
other than /bin/sh this should work OK.

You might also want to adjust this a bit, so the user's .profile
is not read into the shell [speeds up startup]:

	i = 0;
	argv[i++] = "/bin/sh";
	argv[i++] = "-";
	argv[i++] = userprog;

	execv(argv[2], argv+2);
	execv(argv[0], argv+0);
	error("cannot run userprog %s (errno = %d)", userprog, errno);

DISCLAIMER: I rarely work under System V, so my point of view may
be a little off base; SunOS 4.1 may be "the bridge to SysVr4", but
it still gives me all the goodies that I am all to accustomed to :-)
without warning me when something ain't SysV'ish.
--
Greg Limes   limes at sun.com   ...!sun!limes   73327,2473   CGDB02A [choose one]
		A Fool and his Money are soon Partying ...



More information about the Comp.unix.wizards mailing list