🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sgi.misc
Article #193

Re: How can I rlogin with the DISPLAY envar propagated?

#193
From: Phil Karlton
Date: Fri, 08 Jan 1993 19:31
189 lines
5928 bytes
In article <1993Jan8.000124.1271@sol.ctr.columbia.edu>, penev@venezia writes:

    I work on a X terminal, connected to a network of Indigos (4.0.1) and a
    Crimson(4.0.4). Usually I connect to a certain host and start Xsgi and 4Dwm
    from it. As long as I work on the same host, My DISPLAY points
    correctly to my Xterminal. When I wont to do computations on a
    different machine though, I have to rlogin there and start and monitor
    the job. The problem is that I no longer have my DISPLAY properly
    pointed at and certain X features (for example the -keymap option of
    xwsh) do not work.

There are scripts around that help you start up an arbitrary application
on a remote host. I use the following which is a hacked up version of
something else I found some time ago.

========================= /usr/local/bin/xrsh ===========================
#! /bin/sh
#
# Usage:
# 	xrsh machine [-l user] 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.

# 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
	echo No program specified. using $clientprog
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
if test $# = 1 ; then
     domain=`domainname`   
     if test x$domain != x ; then
	fullhere=$fullhere.$domain
    fi
fi

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 \
                "sh -c \"DISPLAY=$display  xhost $fullclientmach\""
        sleep 1
	;;
esac

# run the rsh
if test $clientmach != $here -o x"$lflag" != x ; then
	# And start the client
	rsh $fullclientmach -n $lflag \
	    "sh -c \"DISPLAY=$display  $clientprog $args >/dev/null 2>&1 &\""
else
	eval "exec $clientprog $args $debugsh"
fi


===================== end /usr/local/bin/xrsh ===========================

    The man pages [I assume you mean rlogin here. PK] , say that the
    inclusion of DISPLAY propagation is in the to-do list.

I doubt that rlogin will ever be changed to do this. One problem is
that there is no room in the initial handshake to pass the additional
information. Breaking compatibility with the current rlogind would be
a major no-no.

Here is something else you might try. I'm a csh (well really tcsh)
user.  You can temporarily bury extra information in your $TERM
envariable and pluck that out when you get to the remote side. I use
'@' as a separator between my real $TERM and $DISPLAY.  I have this in
my .login file

======================= .login exceprt ==================================
if ($?TERM) then
  if ( $TERM =~ *@* ) then
    eval `echo $TERM | sed 's/\(.*\)@\(.*\)/setenv DISPLAY \2; set term=\1/'`
  endif
endif
if ($?DISPLAY == 0 && $?REMOTEHOST) then
    setenv DISPLAY ${REMOTEHOST}:0
endif

====================== end .login exceprt =================================

and the following in /usr/local/bin/rlogin

====================== /usr/local/bin/rlogin ==============================
#!/bin/csh -f

if ($?DISPLAY) then
    switch ( $DISPLAY )
      case "":
	setenv DISPLAY :0
      case ":*":
      case "unix:*":
      case "localhost:*":
	setenv HOSTNAME `/usr/bsd/hostname`
	setenv YPDOMAIN `echo $HOSTNAME | sed -e 's/[^.]*\.\(.*\)/\1/'`
	if ( "$YPDOMAIN" == "$HOSTNAME" ) then
	    # hostname doesn't contain domain
	    setenv HOSTNAME ${HOSTNAME}.`/usr/bin/domainname`
	endif
 	setenv TERM $term@${HOSTNAME}:`expr $DISPLAY : ".*:\(.*\)"`
 	breaksw
    default
 	setenv TERM $term@$DISPLAY
    endsw
endif

exec /usr/bsd/rlogin $*

====================== end /usr/local/bin/rlogin ==========================

PK
--
Phil Karlton				Silicon Graphics Computer Systems
The Curmudgeon				2011 N. Shoreline Blvd.
					Mountain View, CA  94039-7311
karlton@.sgi.com			415-390-1557
Technical Details
Message-ID: <1ikkq3INNg9q@fido.asd.sgi.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!sgigate!odin!fido!fudge!karlton
References: <1993Jan8.000124.1271@sol.ctr.columbia.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!sgiblab!sgigate!odin!fido!fudge!karlton
From: karlton@fudge.asd.sgi.com (Phil Karlton)
Newsgroups: comp.sys.sgi.misc
Subject: Re: How can I rlogin with the DISPLAY envar propagated?
Date: 8 Jan 1993 19:31:15 GMT
Organization: Silicon Graphics, Inc.  Mountain View, CA
Lines: 189
Message-ID: <1ikkq3INNg9q@fido.asd.sgi.com>
References: <1993Jan8.000124.1271@sol.ctr.columbia.edu>
NNTP-Posting-Host: fudge.asd.sgi.com