whoami?

Tom Betz betz at marob.uucp
Tue Jan 1 09:31:32 AEST 1991


Quoth jfh at rpp386.cactus.org (John F Haugh II) in <18865 at rpp386.cactus.org>:
|From: article <6537 at crash.cts.com> :
|>What I want is something similiar to the BSD/SunOS whoami.  For example, in a
|>.cshrc file, I want to be able to do this:
|>
|>if (`whoami` == "root") then
|> set prompt = "#"
|>else
|> set prompt = "%"
|>endif
|>
|
|Try something like this -
|
|% id | sed -e 's/^[^(]*(\([^)]*\)).*$/\1/'
|jfh
|
|which would give you -
|
|if ( `id | sed -e 's/^[^(]*(\([^)]*\)).*$/\1/'` == "root" ) then
|	set prompt = "#"
|else

FWIW, Here's the ksh version, removed from my .kshrc:
 
 MYPROMPT=""
 if /bin/id | /bin/grep "uid=0" > /dev/null
  then	MYPROMPT="#"
 fi
 MYPROMPT=${MYPROMPT}`/bin/tty | /usr/bin/cut -c9,10`
 PS1='$MYPROMPT ! $PWD> '
 export PS1
   
This has the added benefit of displaying the current tty# and ksh
history counter, as well as the cwd and a different symbol for
root or non-root user.

-- 
--------------           "Healt ut industri di go hond-e-hond."
Tom Betz     | -----------------------------------------------------------------
914-375-1510 | marob!upaya!tbetz at phri.nyu.edu betz at marob.uucp%phri.nyu.edu
GBS          | {att,philabs,rutgers,cmcl2}!phri!marob!upaya!tbetz



More information about the Comp.unix.xenix.sco mailing list