[comp.unix.wizards] One solution to

rdong@MSRI.ORG (Rui-Tao Dong) (03/22/91)

In article <1991Mar20.154258.1439@resam.dk> andrew@resam.dk (Leif Andrew Rump) writes:
>Some of the quick reader may have read (before I cancelled the
>article: <1991Mar20.142203.682@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@ambra.dk, phone: +45 39 27 11 77                /
>Currently at Scandinavian Airline Systems                =======/
>UUCP: andrew@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@resam.dk whiccccch may BeCoMe sOmEthIng
>like <wheee>w@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@borel.msri.org

s1039@heron.qz.se (Lars Magnusson) (03/22/91)

In article <9103211956.AA11855@msri.org> you write:
>In article <1991Mar20.154258.1439@resam.dk> andrew@resam.dk (Leif Andrew Rump) writes:
..........
>>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!
........
>>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)?
>>
>>Leif Andrew Rump, AmbraSoft A/S, Stroedamvej 50, DK-2100 Copenhagen OE, Denmark
.........
>
>	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.
>
.........
>You should rlogin to a remote host by doing
>
>	> xnrsh remote_host xterm 
>
>or 
.........
>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? 
>
........
>	Rui - Tao  Dong         |       (415) 237 - 7628 (H)

An alternative, depending a bit on loginnames(ie. are several individuals
usin tha same login) and X's functionality in an rlogin-situation, is the
solution i'm presently are using to distinguis between consol-login and 
telnet-login ftom a PC to a Sparc WS.

In .login I have following construction.
---------- .login ----------
set  $PTYPE = `$HOME/bin/ptst` 
if ($PTYPE == 'p') then
	set term = vt100
else 
	set term = sun
endif
--------
------- ptst  ---------
ps -x | grep "\-csh" | awk '{print $2; exit }' | cut -c1
-----------------------

If your at consol the value is "c" as in console, otherwise it's
"p" for ptty. I am only using it for setting up terminal, but if
your not sharing som pseudo-anonymous login with other users, and
Xterm on the local mashine does'n demand any special .loginshells
you should be able to control the login enviroment in this way. 

I could have had different PATH defined, but since I don't need it ....

The ptst should have been "who am i | cut -cX " insted, but both 
ps and who sends out som codes, that cut does not like on the SUN,
at least I gave up. The ideal would have been to put it all in .login
but also her it were problems. But as it is, it works just fine.

 --------------------------------------------------------------------------
 Lars Magnusson                      ! EUNET : lmag@z.amu.se
 Dept. of Computing 		     ! KOM   : s1039 (s1039@heron.QZ.SE)
 AMU Jamtland 			     ! Tel   : + 46  63 14 56 00
 Box 603  			     ! Fax   : + 46  63 12 33 42
 832 01 Froson   (Ostersund)	     !
 Sweden				     ! 
             (Ostersund - candidate for Winter Olympics 1998)	 
 ==========================================================================