home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / question / 13619 < prev    next >
Encoding:
Text File  |  1992-11-19  |  3.5 KB  |  102 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!mcsun!sunic!ericom!eos.ericsson.se!etxmesa
  3. From: etxmesa@eos.ericsson.se (Michael Salmon)
  4. Subject: Re: how do I know on which console I work ?
  5. Message-ID: <1992Nov19.094105.5693@ericsson.se>
  6. Sender: news@ericsson.se
  7. Nntp-Posting-Host: eos6c02.ericsson.se
  8. Reply-To: etxmesa@eos.ericsson.se (Michael Salmon)
  9. Organization: Ericsson Telecom AB
  10. References:  <1992Nov18.155304.736@vms.huji.ac.il>
  11. Distribution: comp.unix.questions,world
  12. Date: Thu, 19 Nov 1992 09:41:05 GMT
  13. Lines: 87
  14.  
  15. In article <1992Nov18.155304.736@vms.huji.ac.il>, errera@shum.cc.huji.ac.il (errera alfred) writes:
  16. |> Hello.
  17. |> We have a system of some SPARC 1 & 2 and some sun386i used as X terminal.
  18. |> We do a lot of rlogin from one machine to another .
  19. |> My question is : how do I know what is the console I work on?
  20. |> namely how do I know the right setting for the DISPLAY variable so that
  21. |> X programs will run on my display even when I do rlogin ?
  22. |> please email or post the answer.
  23. |> thanks a lot.
  24. |> Eliel
  25. |> errera@shum.cc.huji.ac.il
  26.  
  27. This is a repost. I have since used this technique very successfully.
  28. There is a catch though. Some systems only store the first 16
  29. characters of the remote sites name and that can cause a problem.
  30.  
  31. In article <3842@bimacs.BITNET> 
  32. yedidya@bimacs.BITNET (Yedidya Israel) writes:
  33. >
  34. >Hello net.
  35. >
  36. >Can I get help with writing a script that will define my DISPLAY
  37. >environment variable from .cshrc according to the environment I
  38. >telnetted/rlogined from.
  39. >
  40. >I.e. if I telnet from a regular terminal (say vt100) then do not
  41. >define $DISPLAY at all. If I telnet from an xterm or dxterm or aixterm
  42. >X environments define my $DISPLAY to the existing one (if exists) or
  43. >derive it from who am i.
  44.  
  45. On our Apollo (BSD) systems I do:
  46.  
  47. set host = `hostname`
  48. #
  49. # Set the default X Windows server name - set to the name of the host
  50. # the user logged in from, unless it was the terminal server (tserver).
  51. # Also strip off the local domain name (.chem.utoronto.ca) if possible.
  52. #
  53. setenv DISPLAY "${host}:0"
  54. set displayhost=`who am i | sed -e 's/.*(//' -e 's/).*$//' -e 's/\.chem\.utoronto\.ca$//'`
  55. if ("$#displayhost" == "1") then
  56.    if ("$displayhost" != "tserver") then
  57.       setenv DISPLAY $displayhost\:0
  58.    endif
  59. endif
  60. unset displayhost
  61.  
  62. and on our HP (SYSV-sortof) systems I do:
  63.  
  64. set host = `hostname`
  65. #
  66. # Set the default X Windows server name - set to the name of the host
  67. # the user logged in from, unless it was the terminal server (tserver).
  68. # Also strip off the local domain name (.chem.utoronto.ca) if possible.
  69. #
  70. setenv DISPLAY "${host}:0"
  71. tty -s
  72. if ("$status" == "0") then
  73.    set displayhost=`who am i -R | sed -e 's/.*(//' -e 's/).*$//' -e 's/\.chem\.utoronto\.ca$//'`
  74.    if ("$#displayhost" == "1") then
  75.       if ("$displayhost" != "tserver") then
  76.          setenv DISPLAY $displayhost\:0
  77.       endif
  78.    endif
  79.    unset displayhost
  80. endif
  81.  
  82. You will have to surround this with code to only do it for $TERM types
  83. you want. You'll just have to trust the user hasn't messed with $TERM;
  84. if the wrong $TERM is propagated from the remote system, tough luck for
  85. the user. It is possible to send some messages to some terminals
  86. and check the response (this works for vt100/xterm) so that might be
  87. a way to check out the terminal type.
  88. -- 
  89. What are the chances that any computer system will ever "work" properly?
  90. ... and Slim just left town. -*- Mike Peterson, SysAdmin, U/Toronto Chemistry
  91.  
  92. -- 
  93.  
  94. Michael Salmon
  95.  
  96. #include    <standard.disclaimer>
  97. #include    <witty.saying>
  98. #include    <fancy.pseudo.graphics>
  99.  
  100. Ericsson Telecom AB
  101. Stockholm
  102.