home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.sgi
- Path: sparky!uunet!gatech!gsusgi1.gsu.edu!gsusgi1.gsu.edu!syscrc
- From: syscrc@pickle.gsu.edu (Randy Carpenter)
- Subject: Re: finding out who's on the console
- Message-ID: <syscrc.724365907@gsusgi1.gsu.edu>
- Organization: Georgia State University
- References: <34621@adm.brl.mil>
- Date: Mon, 14 Dec 1992 20:45:07 GMT
- Lines: 53
-
- hofmann@nova.tat.physik.uni-tuebingen.de (Bernhard Hofmann) writes:
-
- >rcaslis@hydra.acs.uci.edu (Russell Caslis) writes:
- >
- >
- >>Does anyone know an easy way to tell what user is sitting at the console? I'm
- >>converting a perl script of mine from SunOS to IRIX and I need to know which
- >>user is logged into the console (if anyone).
- >
- >I've hacked a little bash-function that does the job well enough for me.
- >The idea (in case you're not using the bash :-) is to look at the end of
- >/usr/adm/SYSLOG for a line containing 'Xsession:'. It contains all
- >the information you need.
- >
- >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 }
- >
- >I'm aware that it's quick and dirty. If anybody has any suggestions for
- >improvements, please let me know.
- >
- >Bernhard
-
- Long ago, someone posted a solution and I'm still using it today.
- The idea is to create a file called "/etc/console_user" containing the
- login of the person logged into the system.
-
- In /usr/lib/X11/xdm, there are 2 files of interest: Xstartup and Xreset.
- Put the following in the Xstartup file:
-
- echo $USER > /etc/console_user
-
- Put the following in the Xreset file:
-
- /bin/rm -f /etc/console_user
-
- I wrote a "w" replacement script that would print the contents of the
- /etc/console_user file. (I couldn't figure out a shell alias that would
- work):
-
- #!/bin/sh
- if /bin/test -f /etc/console_user; then
- /usr/bsd/w
- /bin/echo `cat /etc/console_user` is on the graphics monitor.
- else
- /usr/bsd/w
- fi
-
- Put this in your $HOME/bin. Then, "alias w ~/bin/w".
- Hope this helps.
- --
- ===========================================================================
- Randy Carpenter rcarpent@gsu.edu % Got a light?
- Georgia State University (404) 651-2648 No match.
- Wells Computer Center %
-