Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!natinst!sequoia!rpp386!jfh From: jfh@rpp386.cactus.org (John F Haugh II) Newsgroups: comp.unix.xenix.sco Subject: Re: whoami? Message-ID: <18865@rpp386.cactus.org> Date: 27 Dec 90 15:33:53 GMT References: <6537@crash.cts.com> Reply-To: jfh@rpp386.cactus.org (John F Haugh II) Organization: Lone Star Cafe and BBS Service Lines: 30 X-Clever-Slogan: Recycle or Die. In article <6537@crash.cts.com> jca@pnet01.cts.com (John C. Archambeau) writes: >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 > >Something like that. Somebody gave me a code fragment in e-mail that does >return what I want, but shell scripts bomb. Any idea why? 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 set prompt = "%" endif -- John F. Haugh II UUCP: ...!cs.utexas.edu!rpp386!jfh Ma Bell: (512) 832-8832 Domain: jfh@rpp386.cactus.org "While you are here, your wives and girlfriends are dating handsome American movie and TV stars. Stars like Tom Selleck, Bruce Willis, and Bart Simpson."