Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: yair@cs.huji.ac.il (Yair Friedman)
Subject: Re: Any script for setting the DISPLAY variable?
Date: 06 Oct 1994 15:24:21 GMT	[thread overview]
Message-ID: <YAIR.94Oct6172421@mangal.cs.huji.ac.il> (raw)
In-Reply-To: monnier@di.epfl.ch's message of 4 Oct 1994 16:16:11 GMT

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 4465 bytes --]

>>>>> In article <36rv4b$fnk@info.epfl.ch>, monnier@di.epfl.ch (Stefan Monnier) writes:

SM> In article <35s3f6$4es@bigdog.fred.net>,  <mahesh@evb.com> 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 <hostname> �-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
----------------------------------------------------------------------------


  parent reply	other threads:[~1994-10-06 15:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-09-22 14:13 Any script for setting the DISPLAY variable? news
1994-10-03 21:11 ` Ben Taylor
1994-10-04 16:16 ` Stefan Monnier
1994-10-05 18:05   ` John Vanderpool
1994-10-06 15:24   ` Yair Friedman [this message]
1994-10-08 14:07     ` Stefan Monnier
1994-10-05 15:49 ` Philip Shearer @ZUO-DC EBS-Team
1994-10-06 15:49   ` Sean J. Anaya
1994-10-07 15:50     ` Georges Dubus
1994-10-07 16:07       ` Q. Alex Zhao
1994-10-06 13:30 ` Mario Klebsch DG1AM
1994-10-06 18:37   ` Michael Meissner
1994-10-07 20:38   ` Greg Walker
1994-10-10 16:33     ` Mario Klebsch DG1AM
1994-10-13 14:07       ` Greg Walker
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox