home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sys / sgi / misc / 211 < prev    next >
Encoding:
Internet Message Format  |  1993-01-08  |  5.6 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!sgigate!odin!fido!fudge!karlton
  2. From: karlton@fudge.asd.sgi.com (Phil Karlton)
  3. Newsgroups: comp.sys.sgi.misc
  4. Subject: Re: How can I rlogin with the DISPLAY envar propagated?
  5. Date: 8 Jan 1993 19:31:15 GMT
  6. Organization: Silicon Graphics, Inc.  Mountain View, CA
  7. Lines: 189
  8. Message-ID: <1ikkq3INNg9q@fido.asd.sgi.com>
  9. References: <1993Jan8.000124.1271@sol.ctr.columbia.edu>
  10. NNTP-Posting-Host: fudge.asd.sgi.com
  11.  
  12.  
  13. In article <1993Jan8.000124.1271@sol.ctr.columbia.edu>, penev@venezia writes:
  14.  
  15.     I work on a X terminal, connected to a network of Indigos (4.0.1) and a
  16.     Crimson(4.0.4). Usually I connect to a certain host and start Xsgi and 4Dwm
  17.     from it. As long as I work on the same host, My DISPLAY points
  18.     correctly to my Xterminal. When I wont to do computations on a
  19.     different machine though, I have to rlogin there and start and monitor
  20.     the job. The problem is that I no longer have my DISPLAY properly
  21.     pointed at and certain X features (for example the -keymap option of
  22.     xwsh) do not work.
  23.  
  24. There are scripts around that help you start up an arbitrary application
  25. on a remote host. I use the following which is a hacked up version of
  26. something else I found some time ago.
  27.  
  28. ========================= /usr/local/bin/xrsh ===========================
  29. #! /bin/sh
  30. #
  31. # Usage:
  32. #     xrsh machine [-l user] cmd [ args... ]
  33. #
  34. # Runs 'cmd args...' on 'machine' (optionally as 'user').
  35. # If 'machine' is the local host (and -l user is not given), then the
  36. # 'cmd' is run directly, instead of using rsh.
  37. # Tries to make sure no extraneous rsh, rshd, or sh processes are left.
  38. # Runs an 'xhost' first to allow access (rsh-ing it to the DISPLAY
  39. # machine if necessary.
  40.  
  41. # Parse off rsh initial args
  42. fullclientmach=${1-"noclientspecified"}
  43. if test x$fullclientmach != xnoclientspecified ; then
  44.         shift
  45. fi
  46.  
  47. while true; do
  48.     case $1 in 
  49.     -l)    lflag="-l $2" ; shift ;;
  50.     *)    break ;;
  51.     esac
  52.     shift
  53. done
  54.  
  55. # Client program name defaults to xterm
  56. clientprog=${1-"noclientspecified"}
  57. if test x$clientprog != xnoclientspecified ; then
  58.         shift
  59. else
  60.     clientprog=xterm
  61.     echo No program specified. using $clientprog
  62. fi
  63.  
  64. args=$*
  65.  
  66. #figure out where we are running now and where the server is running
  67. fullhere=${FULLHOST-`hostname`}
  68. display=${DISPLAY=$fullhere:0}
  69.  
  70. oldIFS=$IFS
  71. IFS="$oldIFS."
  72. set -$- $fullhere
  73. here=$1
  74. IFS=$oldIFS
  75. if test $# = 1 ; then
  76.      domain=`domainname`   
  77.      if test x$domain != x ; then
  78.     fullhere=$fullhere.$domain
  79.     fi
  80. fi
  81.  
  82. IFS="$oldIFS:"
  83. set -$- $display
  84. if test $# = 2 ; then
  85.     displaynum=$2
  86.     fullservermach=$1
  87. else
  88.     displaynum=$1
  89.     fullservermach=$fullhere
  90.         display=$fullhere:$displaynum
  91. fi
  92. IFS=$oldIFS
  93.  
  94. #Check if $DISPLAY was unix:0 localhost:0 or just :0 
  95. case x$fullservermach in
  96.     xunix | x | xlocalhost)
  97.         display=$fullhere:$displaynum
  98.         fullservermach=$fullhere
  99.     ;;
  100. esac
  101.  
  102. if test x$fullclientmach = xnoclientspecified ; then
  103.         fullclientmach=$fullservermach
  104. fi
  105.  
  106. IFS="$oldIFS."
  107. set -$- $fullclientmach
  108. clientmach=$1
  109. IFS=$oldIFS
  110.  
  111. debugcsh=${XDEBUG-">& /dev/null &"}
  112. debugsh=${XDEBUG-">/dev/null 2>&1 &"}
  113. # try to run xhost on remote host cuz server is not here
  114. case $fullservermach in
  115.     $fullhere)
  116.     case $fullclientmach in
  117.         $fullhere) ;;
  118.         *) eval xhost $fullclientmach $debugsh ;;
  119.     esac
  120.     ;;
  121.     *)
  122.         rsh $fullservermach -n \
  123.                 "sh -c \"DISPLAY=$display  xhost $fullclientmach\""
  124.         sleep 1
  125.     ;;
  126. esac
  127.  
  128. # run the rsh
  129. if test $clientmach != $here -o x"$lflag" != x ; then
  130.     # And start the client
  131.     rsh $fullclientmach -n $lflag \
  132.         "sh -c \"DISPLAY=$display  $clientprog $args >/dev/null 2>&1 &\""
  133. else
  134.     eval "exec $clientprog $args $debugsh"
  135. fi
  136.  
  137.  
  138. ===================== end /usr/local/bin/xrsh ===========================
  139.  
  140.     The man pages [I assume you mean rlogin here. PK] , say that the
  141.     inclusion of DISPLAY propagation is in the to-do list.
  142.  
  143. I doubt that rlogin will ever be changed to do this. One problem is
  144. that there is no room in the initial handshake to pass the additional
  145. information. Breaking compatibility with the current rlogind would be
  146. a major no-no.
  147.  
  148. Here is something else you might try. I'm a csh (well really tcsh)
  149. user.  You can temporarily bury extra information in your $TERM
  150. envariable and pluck that out when you get to the remote side. I use
  151. '@' as a separator between my real $TERM and $DISPLAY.  I have this in
  152. my .login file
  153.  
  154. ======================= .login exceprt ==================================
  155. if ($?TERM) then
  156.   if ( $TERM =~ *@* ) then
  157.     eval `echo $TERM | sed 's/\(.*\)@\(.*\)/setenv DISPLAY \2; set term=\1/'`
  158.   endif
  159. endif
  160. if ($?DISPLAY == 0 && $?REMOTEHOST) then
  161.     setenv DISPLAY ${REMOTEHOST}:0
  162. endif
  163.  
  164. ====================== end .login exceprt =================================
  165.  
  166. and the following in /usr/local/bin/rlogin
  167.  
  168. ====================== /usr/local/bin/rlogin ==============================
  169. #!/bin/csh -f
  170.  
  171. if ($?DISPLAY) then
  172.     switch ( $DISPLAY )
  173.       case "":
  174.     setenv DISPLAY :0
  175.       case ":*":
  176.       case "unix:*":
  177.       case "localhost:*":
  178.     setenv HOSTNAME `/usr/bsd/hostname`
  179.     setenv YPDOMAIN `echo $HOSTNAME | sed -e 's/[^.]*\.\(.*\)/\1/'`
  180.     if ( "$YPDOMAIN" == "$HOSTNAME" ) then
  181.         # hostname doesn't contain domain
  182.         setenv HOSTNAME ${HOSTNAME}.`/usr/bin/domainname`
  183.     endif
  184.      setenv TERM $term@${HOSTNAME}:`expr $DISPLAY : ".*:\(.*\)"`
  185.      breaksw
  186.     default
  187.      setenv TERM $term@$DISPLAY
  188.     endsw
  189. endif
  190.  
  191. exec /usr/bsd/rlogin $*
  192.  
  193. ====================== end /usr/local/bin/rlogin ==========================
  194.  
  195. PK
  196. --
  197. Phil Karlton                Silicon Graphics Computer Systems
  198. The Curmudgeon                2011 N. Shoreline Blvd.
  199.                     Mountain View, CA  94039-7311
  200. karlton@.sgi.com            415-390-1557
  201.