home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-bin / x11r6.1 / bin / xon < prev    next >
Encoding:
Text File  |  1996-10-17  |  2.1 KB  |  128 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.     fullname=`hostname`
  32.     hostname=`echo $fullname | sed 's/\..*$//'`
  33.     if [ $hostname = $target ] || [ $fullname = $target ]; then
  34.         DISPLAY=$DISPLAY
  35.         rcmd="sh -c"
  36.     else
  37.         DISPLAY=$fullname$DISPLAY
  38.     fi
  39.     ;;
  40. esac
  41. username=
  42. sess_mangr=
  43. xauth=
  44. case x$XUSERFILESEARCHPATH in
  45. x)
  46.     xpath='HOME=${HOME-`pwd`} '
  47.     ;;
  48. *)
  49.     xpath='HOME=${HOME-`pwd`} XUSERFILESEARCHPATH=${XUSERFILESEARCHPATH-"'"$XUSERFILESEARCHPATH"'"} '
  50.     ;;
  51. esac
  52. redirect=" < /dev/null > /dev/null 2>&1 &"
  53. command=
  54. ls=-ls
  55. continue=:
  56. while $continue; do
  57.     case $1 in
  58.     -user)
  59.         shift
  60.         username="-l $1"
  61.         label="$target $1"
  62.         rcmd="$rsh $target $username -n"
  63.         shift
  64.         case x$XAUTHORITY in
  65.         x)
  66.             XAUTHORITY="$HOME/.Xauthority"
  67.             ;;
  68.         esac
  69.         case x$XUSERFILESEARCHPATH in
  70.         x)
  71.             ;;
  72.         *)
  73.             xpath="XUSERFILESEARCHPATH=$XUSERFILESEARCHPATH "
  74.             ;;
  75.         esac
  76.         ;;
  77.     -access)
  78.         shift
  79.         xhost +$target
  80.         ;;
  81.     -name)
  82.         shift
  83.         label="$1"
  84.         resource="$1"
  85.         shift
  86.         ;;
  87.     -nols)
  88.         shift
  89.         ls=
  90.         ;;
  91.     -debug)
  92.         shift
  93.         redirect=
  94.         ;;
  95.     -screen)
  96.         shift
  97.         DISPLAY=`echo $DISPLAY | sed 's/:\\([0-9][0-9]*\\)\\.[0-9]/:\1/'`.$1
  98.         shift
  99.         ;;
  100.     *)
  101.         continue=false
  102.         ;;
  103.     esac
  104. done
  105. case x$XAUTHORITY in
  106. x)
  107.     ;;
  108. x*)
  109.     xauth="XAUTHORITY=$XAUTHORITY "
  110.     ;;
  111. esac
  112. case x$SESSION_MANAGER in
  113. x)
  114.     ;;
  115. x*)
  116.     sess_mangr="SESSION_MANAGER=$SESSION_MANAGER "
  117.     ;;
  118. esac
  119. vars="$xpath$xauth$sess_mangr"DISPLAY="$DISPLAY"
  120. case $# in
  121. 0)
  122.     $rcmd 'sh -c '"'$vars"' xterm '$ls' -name "'"$resource"'" -T "'"$label"'" -n "'"$label"'" '"$redirect'"
  123.     ;;
  124. *)
  125.     $rcmd 'sh -c '"'$vars"' '"$*$redirect'"
  126.     ;;
  127. esac
  128.