home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / sgi / 18014 < prev    next >
Encoding:
Text File  |  1992-12-14  |  2.4 KB  |  64 lines

  1. Newsgroups: comp.sys.sgi
  2. Path: sparky!uunet!gatech!gsusgi1.gsu.edu!gsusgi1.gsu.edu!syscrc
  3. From: syscrc@pickle.gsu.edu (Randy Carpenter)
  4. Subject: Re: finding out who's on the console
  5. Message-ID: <syscrc.724365907@gsusgi1.gsu.edu>
  6. Organization: Georgia State University
  7. References: <34621@adm.brl.mil>
  8. Date: Mon, 14 Dec 1992 20:45:07 GMT
  9. Lines: 53
  10.  
  11. hofmann@nova.tat.physik.uni-tuebingen.de (Bernhard Hofmann) writes:
  12.  
  13. >rcaslis@hydra.acs.uci.edu (Russell Caslis) writes:
  14. >
  15. >
  16. >>Does anyone know an easy way to tell what user is sitting at the console?  I'm
  17. >>converting a perl script of mine from SunOS to IRIX and I need to know which
  18. >>user is logged into the console (if anyone).
  19. >
  20. >I've hacked a little bash-function that does the job well enough for me.
  21. >The idea (in case you're not using the bash :-) is to look at the end of
  22. >/usr/adm/SYSLOG for a line containing 'Xsession:'. It contains all
  23. >the information you need.
  24. >
  25. >konsole() { if test `grep "Xsession:" /usr/adm/SYSLOG | tail -1 | awk -F: '{print $NF; printf "%s", $(NF-1) >"konsoleuser"}' | awk '{print $1}'` != "logout"; then echo -n "The console is used by"; cat konsoleuser; echo "."; else echo "The Console is unused."; fi; rm konsoleuser }
  26. >
  27. >I'm aware that it's quick and dirty. If anybody has any suggestions for
  28. >improvements, please let me know.
  29. >
  30. >Bernhard
  31.  
  32. Long ago, someone posted a solution and I'm still using it today.
  33. The idea is to create a file called "/etc/console_user" containing the
  34. login of the person logged into the system.
  35.  
  36. In /usr/lib/X11/xdm, there are 2 files of interest: Xstartup and Xreset.
  37. Put the following in the Xstartup file:
  38.  
  39.    echo $USER > /etc/console_user
  40.  
  41. Put the following in the Xreset file:
  42.  
  43.    /bin/rm -f /etc/console_user
  44.  
  45. I wrote a "w" replacement script that would print the contents of the
  46. /etc/console_user file.  (I couldn't figure out a shell alias that would
  47. work):
  48.  
  49.    #!/bin/sh
  50.    if /bin/test -f /etc/console_user; then
  51.        /usr/bsd/w
  52.        /bin/echo `cat /etc/console_user`   is on the graphics monitor.
  53.    else
  54.        /usr/bsd/w
  55.    fi
  56.  
  57. Put this in your $HOME/bin.  Then, "alias w ~/bin/w".
  58. Hope this helps.
  59. -- 
  60. ===========================================================================
  61. Randy Carpenter                    rcarpent@gsu.edu          % Got a light?
  62. Georgia State University           (404) 651-2648            No match.
  63. Wells Computer Center                                        %
  64.