Summary of Responses

Guy Harris guy at gorodish.Sun.COM
Thu Sep 15 10:12:38 AEST 1988


> 4.2 BSD UNIX seems to have the -c option, too.
> 
> So far with the poll. I guess, one shouldn't rely on having it when
> working under non-BSD systems (HP-UX, Ultrix).

As most people said, the truth is:

	1) "su" doesn't have a "-c" option.  It is not in 4.2BSD, nor 4.3BSD,
	   nor SunOS, nor System V (Release 2, Release 3).

	2) UNIX shells tend to support a "-c" option, which tells them to take
	   the argument to that option and execute it as a commmand.

	3) The 4.2BSD, 4.3BSD, S5R2, and S5R3 "su" commands will pass any
	   arguments after the user name to the shell that they invoke; the
	   SunOS "su" command is derived either from the 4.2BSD or the 4.3BSD
	   version (depending on the version of SunOS), and I expect that the
	   Ultrix one is based on a 4.xBSD one and the HP-UX one is based on
	   some S5 one.

	   This is documented in the S5 man page, and that man page mentions
	   that you can use "-c" with this.  This is *not* documented in the
	   4BSD man page; the SunOS man page incorrectly states that "su" has a
	   "-c" option, rather than correctly stating that arguments after the
	   username are passed to the shell (the SunOS man page implies that
	   "su -c <command> <user>" works, but it doesn't - you have to do
	   "su <user> -c <command>").

The net result is that "su <user> -c <command>" runs the new user's shell (as
specified in the password file, with a default of "/bin/sh"), with the
arguments "-c" and "<command>".  For the shells in question (Bourne and C, and
derivatives of same such as the Korn shell and "tcsh"), this causes them to
execute the command <command>.



More information about the Comp.unix.questions mailing list