Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!lll-winken!uunet!mcvax!guido From: guido@cwi.nl (Guido van Rossum) Newsgroups: comp.windows.x Subject: Re: Figuring out the right DISPLAY variable when you rlogin. Message-ID: <8054@boring.cwi.nl> Date: 25 Apr 89 15:20:28 GMT References: <2647@buengc.BU.EDU> <19688@iuvax.cs.indiana.edu> <2475@helios.ee.lbl.gov> Sender: news@cwi.nl Reply-To: guido@cwi.nl (Guido van Rossum) Organization: The Royal Society for Prevention of Cruelty to Amoebae Lines: 53 Locally, we use this script (called xremote) which can start an arbitrary program remotely. We also have a specialization (called xrlogin) which is equivalent to "xremote xterm -ls". All this only works for sh or ksh (no csh lovers here). Improvements over other scripts published before: knows not to touch $DISPLAY if it doesn't start with ":" or "unix:"; sets $PATH to find most X utilities (you may have to change this according to local circumstances); and it has a -d option to display error messages in case something is wrong and you can't figure out what because all I/O is lost normally (usually a bad .rhosts file, or a bad path). (The script closes all file descriptors because we encountered some problems in rshd.) #!/bin/sh # # xremote [-d] hostname xclientname [argument] ... # # Run an X client in the background in a remote machine. # The following tricks are necessary: # - set or patch the DISPLAY variable # - set the remote PATH variable case $1 in -d) set -x; shift; redirect="";; *) redirect="/dev/null 2>&1 3>&- 4>&- 5>&- 6>&- 7>&- 8>&- 9>&- &";; esac case $# in 0|1) echo "usage: xremote [-d] hostname xclientname [argument] ..." 1>&2; exit 2;; esac host=$1 shift local=`hostname` case $DISPLAY in :*) display=$local$DISPLAY;; unix:*) display=`echo "$DISPLAY" | sed "s/unix/$local/"`;; *) display=$DISPLAY;; esac rsh "$host" \ "DISPLAY=$display" \ "PATH=:/bin:/usr/bin:/usr/ucb:/usr/local:/usr/local/X/bin" \ "$@ $redirect" $redirect -- Guido van Rossum, Centre for Mathematics and Computer Science (CWI), Amsterdam guido@cwi.nl or mcvax!guido or guido%cwi.nl@uunet.uu.net "Repo man has all night, every night."