[xpert] Re: Setting display name for X windows server

Spencer W. Thomas spencer at eecs.umich.edu
Fri Sep 21 03:38:04 AEST 1990


Archive-name: xrsh/20-Sep-90
Original-posting-by: spencer at eecs.umich.edu (Spencer W. Thomas)
Original-subject: Re: Setting display name for X windows server
Reposted-by: emv at math.lsa.umich.edu (Edward Vielmetti)

[Reposted from comp.windows.x.
Comments on this service to emv at math.lsa.umich.edu (Edward Vielmetti).]

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 at eecs.umich.edu		313-936-2616 (8-6 E[SD]T M-F)



More information about the Alt.sources mailing list