Path: utzoo!attcan!uunet!mailrus!umich!umeecs!zip!spencer From: spencer@eecs.umich.edu (Spencer W. Thomas) Newsgroups: comp.windows.x Subject: Re: Setting display name for X windows server Message-ID: Date: 20 Sep 90 16:10:19 GMT References: <1990Sep12.220114.11571@d.cs.okstate.edu> <1990Sep14.033455.11976@planck.uucp> <150@tdatirv.UUCP> Sender: news@zip.eecs.umich.edu Organization: University of Michigan EECS Dept Lines: 111 In-Reply-To: sarima@tdatirv.UUCP's message of 19 Sep 90 20:09:10 GMT Try this one. I call it xrsh. Martin Friedmann did most of the hard work on it. ---------------- cut here --------------- #! /bin/sh # # Usage: # xrsh [-l user] machine cmd [ args... ] # # Runs 'cmd args...' on 'machine' (optionally as 'user'). # If 'machine' is the local host (and -l user is not given), then the # 'cmd' is run directly, instead of using rsh. # Tries to make sure no extraneous rsh, rshd, or sh processes are left. # Runs an 'xhost' first to allow access (rsh-ing it to the DISPLAY # machine if necessary. # The 'cmd' must support a -display argument. # # Set environment variable XDEBUG to see error messages generated by 'cmd'. # Parse off rsh initial args fullclientmach=${1-"noclientspecified"} if test x$fullclientmach != xnoclientspecified ; then shift fi while true; do case $1 in -l) lflag="-l $2" ; shift ;; *) break ;; esac shift done # Client program name defaults to xterm clientprog=${1-"noclientspecified"} if test x$clientprog != xnoclientspecified ; then shift else clientprog = xterm fi args=$* #figure out where we are running now and where the server is running fullhere=${FULLHOST-`hostname`} display=${DISPLAY=$fullhere:0} oldIFS=$IFS IFS="$oldIFS." set - $fullhere here=$1 IFS="$oldIFS:" set - $display if test $# = 2 ; then displaynum=$2 fullservermach=$1 else displaynum=$1 fullservermach=$fullhere display=$fullhere:$displaynum fi IFS=$oldIFS #Check if $DISPLAY was unix:0 localhost:0 or just :0 case x$fullservermach in xunix | x | xlocalhost) display=$fullhere:$displaynum fullservermach=$fullhere ;; esac if test x$fullclientmach = xnoclientspecified ; then fullclientmach=$fullservermach fi IFS="$OLDifs." set - $fullclientmach clientmach=$1 IFS=$oldIFS debugcsh=${XDEBUG-">& /dev/null &"} debugsh=${XDEBUG-">/dev/null 2>&1 &"} # try to run xhost on remote host cuz server is not here case $fullservermach in $fullhere) case $fullclientmach in $fullhere) ;; *) eval xhost $fullclientmach $debugsh ;; esac ;; *) rsh $fullservermach -n \ "setenv DISPLAY $display ; xhost $fullclientmach"\ $debugcsh sleep 1 ;; esac # run the rsh if test $clientmach != $here -o x"$lflag" != x ; then # And start the client rsh $fullclientmach -n $lflag "$clientprog -display $display $args $debugcsh" else eval "exec $clientprog -display $DISPLAY $args $debugsh" fi ---------------- cut here ----------------- -- =Spencer W. Thomas EECS Dept, U of Michigan, Ann Arbor, MI 48109 spencer@eecs.umich.edu 313-936-2616 (8-6 E[SD]T M-F)