One solution to (Re: How do a login shell detect that it is "remote")

Rui-Tao Dong rdong at MSRI.ORG
Fri Mar 22 05:56:09 AEST 1991


In article <1991Mar20.154258.1439 at resam.dk> andrew at resam.dk (Leif Andrew Rump) writes:
>Some of the quick reader may have read (before I cancelled the
>article: <1991Mar20.142203.682 at resam.dk>) about my problems getting
>dbxtool (an OpenLook & SunView GUI frontend to dbx) up and running!
>
>Well the problem boiled down because suddenly I found out that when I
>use rlogin to log in on a remote site, I get the path defined in the
>login scripts on the remote workstation and it is not possible to get
>the path from the workstation that I'm physical located at.  That's
>logical because the workstation I rlogin into may be something almost
>but not entirely unlike the SunSparc I'm looking at!
>
>BUT!
>
>When I start OpenWindows 2.0 (Sun's version of X) it changes my path
>so $OPENWINHOME/bin/xview become the first item in it! OK, because
>then I run the OpenWindows programs instead of SunView programs which
>is located in /usr/bin (!)
>
>BUT!
>
>When I rlogin to another workstation I get the path from the other
>workstation - WITHOUT $OPENWINHOME/bin/xview - i.e. I run the SunView
>versions in /usr/bin instead - which doesn't like to open windows on
>remote sites!
>
>HOW do I detect that I'm logged in from a remote site (I know that
>is cheating, but I need to put in the path again)?
>
>AND NO I can't put it in from the beginning - try it and you'll see
>the software fight of the century to the rights to own the screen!
>
>
>Any suggestions?
>
>Leif Andrew
>
>
>Leif Andrew Rump, AmbraSoft A/S, Stroedamvej 50, DK-2100 Copenhagen OE, Denmark
>UUCP: andrew at ambra.dk, phone: +45 39 27 11 77                /
>Currently at Scandinavian Airline Systems                =======/
>UUCP: andrew at resam.dk, phone: +45 32 32 51 54                \
>SAS, RESAM Project Office, CPHML-V, P.O.BOX 150, DK-2770 Kastrup, Denmark
>
>NOTICE: 'Cause of SendMail ConFiGuRation FaultS weee may experiienc ProBleeems
>wiiiiiiith our return add<zap> andrew at resam.dk whiccccch may BeCoMe sOmEthIng
>like <wheee>w at cph<click> !%#@#
>			      @$$%$%(&**&(^%$
>					     $#%%^&)(&^T^%^%^^#
>							       login:

	I have more or less the same problem. The additional difficulty I
have is that I some times use standard X11R4 and wish different binaries
for xterm etc.

	I hacked xrsh to xnrsh (Xnews rsh) to do the trick. The point is to
pass the environment variable NEWSSERVER and use it to select PATHs. 

put the following in your ~/.setpaths

--------------------------------------------------
setenv OPENWINHOME /usr/openwin

if ( $?NEWSSERVER == 1 ) then
	
	setenv PATH .:$HOME/bin:/usr/local/bin:/usr/ucb:$OPENWINHOME/bin:$OPENWINHOME/bin/xview:$OPENWINHOME/demo:/usr/bin/X11:/usr/bin:/bin
	setenv MANPATH $OPENWINHOME/man:/usr/local/man:/usr/man
	eval `svenv -env -csh`
else

	setenv PATH .:$HOME/bin:/usr/local/bin:/usr/ucb:/usr/bin/X11:/usr/bin:/bin:$OPENWINHOME/bin:$OPENWINHOME/bin/xview:$OPENWINHOME/demo
	setenv MANPATH /usr/local/man:/usr/man:$OPENWINHOME/man

endif
--------------------------------------------------

and put the shell script xnrsh in your ~/bin
--------------------------------------------------
#!/bin/sh
#
case $# in
0|1) echo "usage: $0 host cmd [args]" 1>&2; exit 1;;
esac

case "X$DISPLAY" in
Xunix:*)
  : ${HOSTNAME=`hostname`}
  DISPLAY=`echo "$DISPLAY" | sed -e "s/^unix:/${HOSTNAME}:/"`
  ;;
X:*)
  : ${HOSTNAME=`hostname`}
  DISPLAY="$HOSTNAME$DISPLAY"
  ;;
esac

commands=${DISPLAY:+"setenv DISPLAY $DISPLAY ;"}\
${NEWSSERVER:+"setenv NEWSSERVER  \"$NEWSSERVER\";"}

host="$1"
shift

exec rsh "$host" -n " $commands source .setpaths ; exec $@ "
--------------------------------------------------

You should rlogin to a remote host by doing

	> xnrsh remote_host xterm 

or 

	> xnrsh remote_host cmdtool


	> xnrsh remote_host emacs

Of course, you will need to set up .rhosts on machines so that you can
login w/o a passwd. And don't forget to pass Xauth infomation or use xhost
to add the remote_host to the access list.

	This is the most satisfaction solution I have found so far. Does
any body have any better ideas? 

Regards,

-------------------------------------------------------------------------
	Rui - Tao  Dong         |       (415) 237 - 7628 (H)
	110 Lakeshore Court     |       (415) 643 - 6048 (O)
	Richmond, CA 94804      |       rdong at borel.msri.org



More information about the Comp.unix.wizards mailing list