home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / admin / 6759 < prev    next >
Encoding:
Text File  |  1992-12-22  |  2.0 KB  |  44 lines

  1. Newsgroups: comp.unix.admin
  2. Path: sparky!uunet!gatech!paladin.american.edu!darwin.sura.net!spool.mu.edu!agate!dog.ee.lbl.gov!news!avalon.nwc.navy.mil!peewee!erik
  3. From: erik@peewee.nwc.navy.mil (Erik van Bronkhorst       Code 3814                               Phone 939-1421)
  4. Subject: Re: showing working dirs of each users
  5. Message-ID: <Bzoo7K.EDH@avalon.nwc.navy.mil>
  6. Sender: usenet@avalon.nwc.navy.mil (NWC News Admin)
  7. Organization: NAVAIRWARCENWPNDIV, China Lake
  8. References: <1992Dec21.082746.23803@latcs1.lat.oz.au> <78677@hydra.gatech.EDU>
  9. Date: Tue, 22 Dec 1992 23:06:55 GMT
  10. Lines: 32
  11.  
  12. In article <78677@hydra.gatech.EDU> glenns@eas.gatech.edu writes:
  13. >In <1992Dec21.082746.23803@latcs1.lat.oz.au> wongm@latcs1.lat.oz.au (M.C. Wong) writes:
  14. >>  I wonder if there is any utility that shows which working dir each
  15. >>  of the users are in, much like the finger and w command but also shows
  16. >>  where they are. Thank you !!
  17. >
  18. >Not that I know of; I do know that it would be a royal pain to do (probably
  19. >involving C and setuid executables) on a SysV box... but if you luck out
  20. >and have BSD or some variant thereof, you can probably cobble something
  21. >together in a shell script, starting like 
  22. >
  23. >ps agxeww | egrep -e [ -][t-][ck]sh | awk {some really funky stuff here}
  24. >
  25.  
  26. Miracle of miracles!  I had never heard of the "eww" options to ps!
  27. On my Sun (4.1.1) this seems to work as long as the user in question
  28. is doing something other than just sitting there logged in.  Try as
  29. I might, I could not get the -csh entry to show a PWD.  I suspect that
  30. since it is = to HOME at login, it is not retained.  (yes, I WAS
  31. in another dir when I tried it on myself).
  32.  
  33.  #
  34. users=`who | field 1`
  35. for user in $users ; do
  36.   echo $user
  37.   ps aueww | grep "USER=$user" | grep PWD | sed 's/^.*PWD=\([^ ]*\).*$/\1/' | sort -u
  38. done
  39.  
  40. Crude but I never bothered to decipher awk.....
  41. -- 
  42. Erik van Bronkhorst KC6UUT DoD#4342585443 AMA#[classified]
  43. "Truth is false and logic lost, now the fourth dimension is crossed..."
  44.