rsh guru question - summary

Tony J Yeates yeates at motcid.UUCP
Wed Apr 24 03:00:46 AEST 1991


I was overwhelmed by the response to my query:-
>Does anybody know a good way to get around this (ie export
>your current environment to rsh).  This seems to be a
>severe restriction.

(There were some more details too)
Thank you all for taking the time to help, here's a brief summary  (their were
many variations, some of which I still need to try) of the replies, :-

1) Reset your path in .cshrc/.kshrc/.tcshrc.  I'm actually doing this now, it
works for ~90% of what I want to do, but it doesn't export my current PATH
only my initial PATH.  Also, I've seen a lot of people "bitten" by altering
their PATH in their .cshrc - it seems a dubious practise IMHO.

2) Use SUN OS command "on".  Definitely a possibility, although it is a little
quirky (e.g. on <hostname>....I can't get a prompt), I'm told its a little
"flakey" but I intend to investigate further.

3) Use: rsh <host> "setenv PATH $PATH; <command>"   (or ksh equiv.)
This works fine - but I don't want to have to type all that in each time I use
an rsh.  Creating a script or alias that works well proved more difficult 
than I had expected.  The best result I got was this:-

	alias rshy  "rsh \!^ \"setenv PATH ${PATH} ;\" \!:2*"

which seems to work (csh & tcsh)e.g. rsh myhost1 'echo $PATH'
(the single quotes are to prevent $PATH being expanded before the rsh is invoked).

-------------------------------------------------------------------------------
JUST FOR INTEREST
=================
Here is one of my attempts to export my whole environment (useful if you have
tools which rely on env. variables):-
[This was going to be another problem - but I just had a flash of inspiration]
alias:
	alias rshx  "rsh \!^ `env | sed -e 's/^/setenv /' | tr '\012' ';'` ; \!:2*"
(Use rshx exactly as you would rsh, rsh <host> <command>)

The sed part should really be replaced with a sed script file that quotes (") the
value of each env. var., like:-
env | sed -e 's/^/setenv /' -e 's/=/="/' -e 's/$/"/' | tr '\012' ';' 
(this works fine on the command line, but I found it a problem in an alias...
a sed-file should prob fix that tho')
-------------------------------

I also wanted to be able to invoke an rsh that would by default to my c.w.d.,
out of the above I salvaged this:-

alias rshp  "rsh \!^ cd $cwd ';' \!:2*"

which seems to work okay (so far!)...doesn't work for rlogins via rsh unfortunatly tho'.
-------------------------------------------------------------------------------



More information about the Comp.unix.shell mailing list