home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / util / scripts / xon.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1991-07-24  |  1.8 KB  |  112 lines

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