From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103734,674f735b36ac5ffe X-Google-Attributes: gid103734,public X-Google-Thread: 1070f0,674f735b36ac5ffe X-Google-Attributes: gid1070f0,public X-Google-Thread: fee84,674f735b36ac5ffe X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-10-07 01:39:35 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!cs.utexas.edu!uunet!zib-berlin.de!ceres.fokus.gmd.de!nntp.gmd.de!dearn!barilvm!vms.huji.ac.il!shum.cc.huji.ac.il!pretzel.cs.huji.ac.il!nntpserver!yair Newsgroups: comp.windows.x,comp.sys.sun.admin,comp.unix.osf.osf1 Subject: Re: Any script for setting the DISPLAY variable? Message-ID: From: yair@cs.huji.ac.il (Yair Friedman) Date: 06 Oct 1994 15:24:21 GMT References: <35s3f6$4es@bigdog.fred.net> <36rv4b$fnk@info.epfl.ch> Distribution: usa Organization: Hebrew University of Jerusalem, Israel NNTP-Posting-Host: mangal.cs.huji.ac.il In-reply-to: monnier@di.epfl.ch's message of 4 Oct 1994 16:16:11 GMT X-Attribution: Yair X-Zippy: Somewhere in Tenafly, New Jersey, a chiropractor is viewing``Leave it to Beaver''! X-Newsreader: GNUS 4.1; NNTP 3.12 X-Posting-Software: GNUS 4.1; NNTP 3.12 Xref: bga.com comp.windows.x:12316 comp.sys.sun.admin:17016 comp.unix.osf.osf1:3916 >>>>> In article <36rv4b$fnk@info.epfl.ch>, monnier@di.epfl.ch (Stefan Monnier) writes: SM> In article <35s3f6$4es@bigdog.fred.net>, wrote: > I rlogin to HP, DEC Alpha OSF1, Sun systems. I have had > some script in .login which would set the DISPLAY variable. > But it uses the 'whoami' command to find out from which > system I have logged in. Unfortunately the output of > whomai is not the same on all these systems. Was wondering > if you folks have some script which would set the DISPLAY > environment variable correctly on ALL systems. SM> Well, GNU who is the same no matter the platform, so you can choose SM> GNU who instead of the standard one. Or you can choose a clever SM> extracting function (that works with all the different format used by SM> the different whos). But of course, the best suggestion I have is to SM> switch to tcsh-6.05 which has a REMOTE env var which does exactly what SM> you want ! SM> Stefan SM> PS: ultimately, the best solution is to telnet instead of rlogin and SM> hope the telnets are recent enough to include the "last" extensions: SM> this allows you to pass any env var to the remote host (as is always SM> done for TERM). This way, the DISPLAY var is kept correct even if you SM> log from X to Y to Z (in which case the "who" thing would try to SM> display on Y) IMHO The best way is to pass the DISPLAY in an rsh, so you don't need to keep any in.rlogin tenet processes so you can just open an xterm Here is what I use In my Wm I have : "sun" !"remst sun exec xterm -name sun -display `xdisplay`&" the xdisplay and remst scripts are givn below: Yair. xdisplay: #!/bin/csh -f set host = `echo $DISPLAY | sed 's/:.*//'` set screen = `echo $DISPLAY | sed 's/.*://'` if ($host == unix | $host == "") then echo `hostname`\:$screen else echo $DISPLAY endif remst: #!/bin/sh # start up xterm (or any other X command) on the specified host # Usage: xon host �arguments� �command� 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 rcmd="rsh $target" case $DISPLAY in unix:*) DISPLAY=`echo $DISPLAY | sed 's/unix//'` ;; esac case $DISPLAY in :*) fullname=`hostname|gawk '{if(index($1, ".")) print $1;else{h=$1;getline<"/etc/resolv.conf";print h "." $2;}}'` 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 vars="$xpath$xauth"DISPLAY="$DISPLAY" case $# in 0) $rcmd 'sh -c '"'$vars"' xterm '$ls' -name "'"$resource"'" -T "'"$label"'" -n "'"$label"'" '"$redirect'" ;; *) $rcmd 'sh -c '"'$vars"' '"$*$redirect'" ;; esac -- ---------------------------------------------------------------------------- Yair I. Friedman yair@cs.huji.ac.il yair@HUJICS.BITNET A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects. -- Robert A. Heinlein ----------------------------------------------------------------------------