home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / shell / 4596 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.2 KB  |  44 lines

  1. Newsgroups: comp.unix.shell
  2. Path: sparky!uunet!wizzy!andyr
  3. From: andyr@wizzy.com (Andy Rabagliati)
  4. Subject: How do I know who I have su'ed to ?
  5. Message-ID: <BxEvKx.IpL@wizzy.com>
  6. Organization: W. Z. I.
  7. Date: Sun, 8 Nov 1992 19:02:56 GMT
  8. Lines: 34
  9.  
  10. I want to know if I have su'ed to another account (especially root) in
  11. one of my windows, by changing the prompt.
  12.  
  13. I am using ksh.  (please, no suggestions like ``but, in [czx]sh ...'')
  14.  
  15. I have the following setup at the moment, which works. However, it seems
  16. clumsy and roundabout, and, ever eager to learn :) I want to know if
  17. there is a Better Way.
  18.  
  19. The problem, as I see it, is that when I have su'ed, there is nothing
  20. that has changed in my environment, even $USER. So, I have to do an
  21. explicit USER= before invoking su.
  22.  
  23. Cheers,   Andy.
  24.  
  25. I have this in .profile :-
  26.  
  27. ENV=~andyr/.kshrc
  28.  
  29. here is my .kshrc :-
  30.  
  31. if [ ?$PS1 ] ; then {                        # interactive
  32.  
  33.     if   [ $USER = root  ] ; then PS1='$PWD#\ ';         # prompt pwd 
  34.     elif [ $USER = andyr ] ; then PS1='${PWD#$HOME}>\ ';     # prompt pwd 
  35.     else              PS1='$PWD%\ '; fi
  36.     su()    {
  37.         if   [ $# -ne 1 ]; then echo "Use su <account>";
  38.         else USER=$1 /bin/su $1; fi
  39.         }
  40. }; fi
  41.  
  42. -- 
  43. andyr@wizzy.com  Andy Rabagliati, RR1 Box 33, Wyalusing, PA 18853 (717)746-7780
  44.