Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!exodus!ouroborous.Sun.COM!limes From: limes@ouroborous.Sun.COM (Greg Limes) Newsgroups: comp.unix.wizards Subject: Re: What is a good way to do general execs? Message-ID: <347@exodus.Eng.Sun.COM> Date: 8 Jun 90 18:36:13 GMT References: <438@mtndew.UUCP> Sender: news@exodus.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 34 In article <438@mtndew.UUCP> friedl@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@sun.com ...!sun!limes 73327,2473 CGDB02A [choose one] A Fool and his Money are soon Partying ...