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