#!/bin/sh # start up xterm (or any other X command) on the specified host # Usage: xon host [arguments] [command] # # This was modified for SSH clients by Taiji Yamada (taiji@aihara.co.jp). # # If /usr/local/bin/ssh exits, this xon run using ssh as default remote shell. # case $# in 0) echo "Usage: $0 [-user user] [-name window-name] [-debug]" echo "[-screen screen-number] [command ...]" exit 1 ;; esac target=$1 shift label=$target resource=xterm-$label # begin better seaching remote shell in ssh, remsh, rcmd and rsh # written by taiji@aihara.co.jp at Aug 1 1997 if [ -f /usr/local/bin/ssh -a "`echo $target|/bin/sed -ne 's/\([^.]*\)\.\(.*\)/\2/p'`" != `/bin/domainname` ]; then rsh="/usr/local/bin/ssh -f" elif [ -f /usr/bin/remsh ]; then rsh=/usr/bin/remsh elif [ -f /usr/bin/rcmd ]; then rsh=/usr/bin/rcmd else rsh=rsh fi # end remote shell searching rcmd="$rsh $target" case $DISPLAY in unix:*) DISPLAY=`echo $DISPLAY | sed 's/unix//'` ;; esac case $DISPLAY in :*) fullname=`hostname` hostname=`echo $fullname | sed 's/\..*$//'` if [ $hostname = $target -o $fullname = $target ]; then DISPLAY=$DISPLAY rcmd="sh -c" else DISPLAY=$fullname$DISPLAY fi ;; esac username= 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" 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 if [ "$rsh" != "/usr/local/bin/ssh -f" ]; then vars="$xpath$xauth"DISPLAY="$DISPLAY" else # # DISPLAY is no need and redirect has problem in the case of ssh. # vars="$xpath$xauth" redirect= fi case $# in 0) $rcmd 'sh -c '"'$vars"' xterm '$ls' -name "'"$resource"'" -T "'"$label"'" -n "'"$label"'" '"$redirect'" ;; *) $rcmd 'sh -c '"'$vars"' '"$*$redirect'" ;; esac