home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!spool.mu.edu!sol.ctr.columbia.edu!destroyer!fmsrl7!ef2007!fmsrl5!ope001!mjo
- From: mjo@iao.ford.com (Mike O'Connor)
- Newsgroups: comp.windows.x
- Subject: Re: setting DISPLAY env variable
- Date: 22 Dec 1992 22:17:31 GMT
- Organization: Not an official spokesperson for Ford Motor Company
- Lines: 41
- Message-ID: <1h845rINNe18@ope001.iao.ford.com>
- References: <1h4bp2INNi8u@sol.deakin.OZ.AU> <1992Dec21.130253.1110@ericsson.se>
- Reply-To: Mike O'Connor <mjo@fmsrl7.srl.ford.com>
- NNTP-Posting-Host: localhost
-
- Uhhh... most of these login hacks suffer from the problem that you
- have to perform your logins in a different manner, or are site-dependent.
- Most of the time, you really don't care how the heck it was that you
- accessed your remote site -- you want the DISPLAY to be set anyway.
- My hack below doesn't take care of things like multi-headed displays
- or logins that don't show up in utmp, and is certainly not of the "one
- script for all platforms variety". But it seems to work with tweaking
- here and there with the multitude of platforms I end up connecting to
- here at Ford.
-
- The "where you are coming from" information is available in /dev/kmem.
- Few users/programs can read /dev/kmem -- it's restricted. However,
- netstat does. What I typically do is parse the usually-partial
- "where you came from" information from who, and compare it against
- some netstat output to figure out the IP address of where I'm coming
- from.
-
- Here's a script which works under Ultrix, and you'll probably have to
- tweak it to work under other platforms. I have perl scripts which do
- this much better, but shell scripts work everywhere, which was kind of
- my point. :) Set DISPLAY to the output of the script and you should
- be set.
-
- #!/usr/bin/sh5
- T=`tty | sed 's/.....//'`
- H=`who | fgrep $T | awk '{ f=substr($6,2); print f }' | cut -f1 -d\)`
- if [ $H = ":0.0" ]
- then
- echo "`hostname`:0.0"
- else
- H=`echo $H | cut -c1-12`
- J=`netstat -A -f inet | grep $H | head -1 | cut -c-9`
- K=`netstat -A -n -f inet| grep $J | head -1 | awk '{ f=substr($6,1); print f }'`
- G=`echo $K | awk '{ FS="." ; print $1"."$2"."$3"."$4 }'`
- echo $G:0.0
- fi
- --
- Michael J. O'Connor | Internet: mjo@fmsrl7.srl.ford.com
- Ford Motor Company, OPEO | UUCP: ...!{backbone}!fmsrl7!mjo
- 20000 Rotunda, Bldg. 1-3001 | Phone: +1 (313) 248-1260
- Dearborn, MI 48121 | Fax: +1 (313) 323-6277
-