home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / windows / x / 20499 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  2.4 KB

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