Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

rsh exit code

409 views
Skip to first unread message

Jens-Uwe Spiering

unread,
Aug 18, 2000, 7:24:36 PM8/18/00
to
Hi all,
for a command like this

rsh host -l user test -f /pathtofile/file

i got always success for the return code $?
OK the rsh command succeeded but how can i get the result of the test command?
Thanx for any input
-jens-

Nicholas Dronen

unread,
Aug 18, 2000, 10:45:54 PM8/18/00
to

$ rc=`rsh tuvan 'ls nofile 2> /dev/null ; echo $?'`
$ echo $rc

rc now contains the return code of the command.

Regards,

Nick Dronen

Jens-Uwe Spiering

unread,
Aug 19, 2000, 3:00:00 AM8/19/00
to
Thanks Nick,
the echo is working fine, but as often the next problem is waiting, may be you
have an answer as well
if i rsh host 'test -f /mypath/myfile ; echo $?' everything is fine
but i don't know for wich path and file i should ask in advance so i put
variables

rsh host 'test -f $MyPath/$MyFile ; echo $?'

but that does not work. Perhaps the test command on the remote does not know
the variables although they are known locally when the rsh command is started.
Can i somehow get the remote test command to check for my variables??

-jens-

Nicholas Dronen <ndr...@io.frii.com> wrote in article
<Cxmn5.414$P1k.19...@news.frii.net>...

Nicholas Dronen

unread,
Aug 19, 2000, 3:00:00 AM8/19/00
to
Jens-Uwe Spiering <jens_s...@ste.scitex.com> wrote:
> Thanks Nick,
> the echo is working fine, but as often the next problem is waiting, may be you
> have an answer as well
> if i rsh host 'test -f /mypath/myfile ; echo $?' everything is fine
> but i don't know for wich path and file i should ask in advance so i put
> variables

> rsh host 'test -f $MyPath/$MyFile ; echo $?'

> but that does not work. Perhaps the test command on the remote does not know
> the variables although they are known locally when the rsh command is started.
> Can i somehow get the remote test command to check for my variables??

If the local system environment contains $MyPath and $MyFile, you
need to enclose the command in double quotes -- not single quotes --
to allow your local shell to interpolate the variables.

Regards,

Nick Dronen

Jens-Uwe Spiering

unread,
Aug 20, 2000, 3:00:00 AM8/20/00
to
Yes!
Now are the vars are expanded to their value, but again i get only success in
echo $?
Probably this variable is as well expanded and don't take the return value of
the test command

Exists=`rsh host "test -f $MyPath/$MyFile ; echo $?" `

so i tried to keep that echo $? away from the main shell with again single
quotes and and and...
to no result ;)
Any idea are more than welcome
-jens-

Nicholas Dronen <ndr...@io.frii.com> wrote in article

<lhDn5.433$P1k.19...@news.frii.net>...

Hartwig Bolle

unread,
Aug 20, 2000, 3:00:00 AM8/20/00
to

Hello Jens,

in a korn-shell script try the following:

rc=$(rsh host "test -f $Mypath/$Myfile && echo found || echo failed")

echo $rc

REgards,
Hartwig

Dr. Markus

unread,
Aug 21, 2000, 3:00:00 AM8/21/00
to
In article <8npg5l$gtn$13$1...@news.t-online.com>,
Hi,
you would want to mask the semicolon and other special characters from
rsh like this:
rsh remotehost \(thiscommand \; thatcommand 2\>\&1 \)

h.t.h.
regards, Markus


Sent via Deja.com http://www.deja.com/
Before you buy.

Ralph Corderoy

unread,
Aug 21, 2000, 3:00:00 AM8/21/00
to
> Yes!
> Now are the vars are expanded to their value, but again i get only success in
> echo $?
> Probably this variable is as well expanded and don't take the return value of
> the test command
>
> Exists=`rsh host "test -f $MyPath/$MyFile ; echo $?" `

Either use double quotes and escape the variables (twice) that you
don't want interpolated or switch quoting styles as appropriate.

exists=`rsh host "test -f $mypath/$myfile; echo \\$?"`
exists=`rsh host "test -f $mypath/$myfile; "'echo $?'`


Ralph.


0 new messages