blob: 772b3574a033b28c7485abdbc652a3d211491c8d (
plain)
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
#!/bin/sh
# $Xorg: xon.sh,v 1.4 2000/12/20 16:50:07 pookie Exp $
# $XFree86: xc/programs/scripts/xon.sh,v 1.8 2003/04/03 22:28:01 dawes Exp $
# start up xterm (or any other X command) on the specified host
# Usage: xon host [arguments] [command]
usage() {
if [ -n "$1" ]
then
echo "`basename $0`: $1"
fi
echo ""
echo "Usage: `basename $0` hostname [options] [command ...]"
echo ""
echo "where options include:"
echo " -access add remote host to local host access list"
echo " -debug enable error messages from remote execution"
echo " -name name set alternate application name and window title"
echo " -nols do not pass -ls option to remote xterm"
echo " -remote cmd use cmd to contact remote host"
echo " -screen screen change remote screen number to specified screen"
echo " -user user run remote command as the specified user"
exit 1
}
if [ $# -eq 0 ]
then
usage
fi
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*)
if [ -z "`hostname --version 2>&1 | grep GNU`" ]; then
fullname=`hostname -f`
else
fullname=`hostname`
fi
;;
*)
fullname=`uname -n`
;;
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
-remote)
shift
if [ $rsh != "sh" ]; then
rsh="$1"
rcmd="$rsh $target -n"
fi
shift;;
-user)
shift
if [ $# -eq 0 ]
then
usage "-user option requires an argument"
fi
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
if [ $# -eq 0 ]
then
usage "-name option requires an argument"
fi
label="$1"
resource="$1"
shift
;;
-nols)
shift
ls=
;;
-debug)
shift
redirect=
;;
-screen)
shift
if [ $# -eq 0 ]
then
usage "-screen option requires an argument"
fi
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='PATH=${PATH:+$PATH:}/usr/X11R6/bin '"$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
|