home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1847 < prev    next >
Internet Message Format  |  1990-12-28  |  3KB

  1. From: spencer@eecs.umich.edu (Spencer W. Thomas)
  2. Newsgroups: alt.sources
  3. Subject: [xpert] Re: Setting display name for X windows server
  4. Message-ID: <1990Sep20.173804.13197@math.lsa.umich.edu>
  5. Date: 20 Sep 90 17:38:04 GMT
  6.  
  7. Archive-name: xrsh/20-Sep-90
  8. Original-posting-by: spencer@eecs.umich.edu (Spencer W. Thomas)
  9. Original-subject: Re: Setting display name for X windows server
  10. Reposted-by: emv@math.lsa.umich.edu (Edward Vielmetti)
  11.  
  12. [Reposted from comp.windows.x.
  13. Comments on this service to emv@math.lsa.umich.edu (Edward Vielmetti).]
  14.  
  15. Try this one.  I call it xrsh.  Martin Friedmann did most of the hard
  16. work on it.
  17.  
  18. ---------------- cut here ---------------
  19. #! /bin/sh
  20. #
  21. # Usage:
  22. #     xrsh [-l user] machine cmd [ args... ]
  23. #
  24. # Runs 'cmd args...' on 'machine' (optionally as 'user').
  25. # If 'machine' is the local host (and -l user is not given), then the
  26. # 'cmd' is run directly, instead of using rsh.
  27. # Tries to make sure no extraneous rsh, rshd, or sh processes are left.
  28. # Runs an 'xhost' first to allow access (rsh-ing it to the DISPLAY
  29. # machine if necessary.
  30. # The 'cmd' must support a -display argument.
  31. #
  32. # Set environment variable XDEBUG to see error messages generated by 'cmd'.
  33.  
  34. # Parse off rsh initial args
  35. fullclientmach=${1-"noclientspecified"}
  36. if test x$fullclientmach != xnoclientspecified ; then
  37.         shift
  38. fi
  39.  
  40. while true; do
  41.     case $1 in 
  42.     -l)    lflag="-l $2" ; shift ;;
  43.     *)    break ;;
  44.     esac
  45.     shift
  46. done
  47.  
  48. # Client program name defaults to xterm
  49. clientprog=${1-"noclientspecified"}
  50. if test x$clientprog != xnoclientspecified ; then
  51.         shift
  52. else
  53.     clientprog = xterm
  54. fi
  55.  
  56. args=$*
  57.  
  58. #figure out where we are running now and where the server is running
  59. fullhere=${FULLHOST-`hostname`}
  60. display=${DISPLAY=$fullhere:0}
  61.  
  62. oldIFS=$IFS
  63. IFS="$oldIFS."
  64. set - $fullhere
  65. here=$1
  66.  
  67. IFS="$oldIFS:"
  68. set - $display
  69. if test $# = 2 ; then
  70.     displaynum=$2
  71.     fullservermach=$1
  72. else
  73.     displaynum=$1
  74.     fullservermach=$fullhere
  75.         display=$fullhere:$displaynum
  76. fi
  77. IFS=$oldIFS
  78.  
  79. #Check if $DISPLAY was unix:0 localhost:0 or just :0 
  80. case x$fullservermach in
  81.     xunix | x | xlocalhost)
  82.         display=$fullhere:$displaynum
  83.         fullservermach=$fullhere
  84.     ;;
  85. esac
  86.  
  87. if test x$fullclientmach = xnoclientspecified ; then
  88.         fullclientmach=$fullservermach
  89. fi
  90.  
  91. IFS="$OLDifs."
  92. set - $fullclientmach
  93. clientmach=$1
  94. IFS=$oldIFS
  95.  
  96. debugcsh=${XDEBUG-">& /dev/null &"}
  97. debugsh=${XDEBUG-">/dev/null 2>&1 &"}
  98.  
  99. # try to run xhost on remote host cuz server is not here
  100. case $fullservermach in
  101.     $fullhere)
  102.     case $fullclientmach in
  103.         $fullhere) ;;
  104.         *) eval xhost $fullclientmach $debugsh ;;
  105.     esac
  106.     ;;
  107.     *)
  108.         rsh $fullservermach -n \
  109.                 "setenv DISPLAY $display ; xhost $fullclientmach"\
  110.         $debugcsh
  111.         sleep 1
  112.     ;;
  113. esac
  114.  
  115. # run the rsh
  116. if test $clientmach != $here -o x"$lflag" != x ; then
  117.     # And start the client
  118.     rsh $fullclientmach -n $lflag "$clientprog -display $display $args $debugcsh"
  119. else
  120.     eval "exec $clientprog -display $DISPLAY $args $debugsh"
  121. fi
  122. ---------------- cut here -----------------
  123. --
  124. =Spencer W. Thomas         EECS Dept, U of Michigan, Ann Arbor, MI 48109
  125. spencer@eecs.umich.edu        313-936-2616 (8-6 E[SD]T M-F)
  126.