home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.shell
- Path: sparky!uunet!wizzy!andyr
- From: andyr@wizzy.com (Andy Rabagliati)
- Subject: How do I know who I have su'ed to ?
- Message-ID: <BxEvKx.IpL@wizzy.com>
- Organization: W. Z. I.
- Date: Sun, 8 Nov 1992 19:02:56 GMT
- Lines: 34
-
- I want to know if I have su'ed to another account (especially root) in
- one of my windows, by changing the prompt.
-
- I am using ksh. (please, no suggestions like ``but, in [czx]sh ...'')
-
- I have the following setup at the moment, which works. However, it seems
- clumsy and roundabout, and, ever eager to learn :) I want to know if
- there is a Better Way.
-
- The problem, as I see it, is that when I have su'ed, there is nothing
- that has changed in my environment, even $USER. So, I have to do an
- explicit USER= before invoking su.
-
- Cheers, Andy.
-
- I have this in .profile :-
-
- ENV=~andyr/.kshrc
-
- here is my .kshrc :-
-
- if [ ?$PS1 ] ; then { # interactive
-
- if [ $USER = root ] ; then PS1='$PWD#\ '; # prompt pwd
- elif [ $USER = andyr ] ; then PS1='${PWD#$HOME}>\ '; # prompt pwd
- else PS1='$PWD%\ '; fi
- su() {
- if [ $# -ne 1 ]; then echo "Use su <account>";
- else USER=$1 /bin/su $1; fi
- }
- }; fi
-
- --
- andyr@wizzy.com Andy Rabagliati, RR1 Box 33, Wyalusing, PA 18853 (717)746-7780
-