home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / fj / maillis / xwindow / 18863 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  2.5 KB

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