home *** CD-ROM | disk | FTP | other *** search
/ PC World 2000 February / PCWorld_2000-02_cd.bin / live / usr / X11R6 / bin / xon < prev    next >
Text File  |  1999-09-03  |  2KB  |  135 lines

  1. #!/bin/sh
  2. # $XConsortium: xon.sh,v 1.10 94/12/09 22:53:55 gildea Exp $
  3. # start up xterm (or any other X command) on the specified host
  4. # Usage: xon host [arguments] [command]
  5. case $# in
  6. 0)
  7.     echo "Usage: $0 <hostname> [-user user] [-name window-name] [-debug]"
  8.     echo "[-screen screen-number] [command ...]"
  9.     exit 1
  10.     ;;
  11. esac
  12. target=$1
  13. shift
  14. label=$target
  15. resource=xterm-$label
  16. if [ -f /usr/bin/remsh ]; then
  17.     rsh=/usr/bin/remsh
  18. elif [ -f /usr/bin/rcmd ]; then
  19.     rsh=/usr/bin/rcmd
  20. else
  21.     rsh=rsh
  22. fi
  23. rcmd="$rsh $target -n"
  24. case $DISPLAY in
  25. unix:*)
  26.     DISPLAY=`echo $DISPLAY | sed 's/unix//'`
  27.     ;;
  28. esac
  29. case $DISPLAY in
  30. :*)
  31.     case `uname` in
  32.     Linux*)
  33.         fullname=`hostname -f`
  34.         ;;
  35.     *)
  36.         fullname=`hostname`
  37.         ;;
  38.     esac
  39.     hostname=`echo $fullname | sed 's/\..*$//'`
  40.     if [ $hostname = $target ] || [ $fullname = $target ]; then
  41.         DISPLAY=$DISPLAY
  42.         rcmd="sh -c"
  43.     else
  44.         DISPLAY=$fullname$DISPLAY
  45.     fi
  46.     ;;
  47. esac
  48. username=
  49. sess_mangr=
  50. xauth=
  51. case x$XUSERFILESEARCHPATH in
  52. x)
  53.     xpath='HOME=${HOME-`pwd`} '
  54.     ;;
  55. *)
  56.     xpath='HOME=${HOME-`pwd`} XUSERFILESEARCHPATH=${XUSERFILESEARCHPATH-"'"$XUSERFILESEARCHPATH"'"} '
  57.     ;;
  58. esac
  59. redirect=" < /dev/null > /dev/null 2>&1 &"
  60. command=
  61. ls=-ls
  62. continue=:
  63. while $continue; do
  64.     case $1 in
  65.     -user)
  66.         shift
  67.         username="-l $1"
  68.         label="$target $1"
  69.         rcmd="$rsh $target $username -n"
  70.         shift
  71.         case x$XAUTHORITY in
  72.         x)
  73.             XAUTHORITY="$HOME/.Xauthority"
  74.             ;;
  75.         esac
  76.         case x$XUSERFILESEARCHPATH in
  77.         x)
  78.             ;;
  79.         *)
  80.             xpath="XUSERFILESEARCHPATH=$XUSERFILESEARCHPATH "
  81.             ;;
  82.         esac
  83.         ;;
  84.     -access)
  85.         shift
  86.         xhost +$target
  87.         ;;
  88.     -name)
  89.         shift
  90.         label="$1"
  91.         resource="$1"
  92.         shift
  93.         ;;
  94.     -nols)
  95.         shift
  96.         ls=
  97.         ;;
  98.     -debug)
  99.         shift
  100.         redirect=
  101.         ;;
  102.     -screen)
  103.         shift
  104.         DISPLAY=`echo $DISPLAY | sed 's/:\\([0-9][0-9]*\\)\\.[0-9]/:\1/'`.$1
  105.         shift
  106.         ;;
  107.     *)
  108.         continue=false
  109.         ;;
  110.     esac
  111. done
  112. case x$XAUTHORITY in
  113. x)
  114.     ;;
  115. x*)
  116.     xauth="XAUTHORITY=$XAUTHORITY "
  117.     ;;
  118. esac
  119. case x$SESSION_MANAGER in
  120. x)
  121.     ;;
  122. x*)
  123.     sess_mangr="SESSION_MANAGER=$SESSION_MANAGER "
  124.     ;;
  125. esac
  126. vars="$xpath$xauth$sess_mangr"DISPLAY="$DISPLAY"
  127. case $# in
  128. 0)
  129.     $rcmd 'sh -c '"'$vars"' xterm '$ls' -name "'"$resource"'" -T "'"$label"'" -n "'"$label"'" '"$redirect'"
  130.     ;;
  131. *)
  132.     $rcmd 'sh -c '"'$vars"' '"$*$redirect'"
  133.     ;;
  134. esac
  135.