SUMMARY: rsh command status

From: Mariel Feder (unix.support@central.meralco.com.ph)
Date: Thu Dec 11 1997 - 18:51:48 CST


My original post:

> I want to get the status of the execution of a remote command, invoked
> through remote shell.
> How can I do this ?
>
> To be more clear, an example with an ls will show it better:
>
> On machine1:
> #!/bin/ksh
> # Note: for this test /pepe doesn't exist on machine1
> ls /pepe
> echo $?
>
> $? is not 0, because the ls failed.
>
> How can I do to find this out, when the ls is executed remotely?
>
> On machine2:
> #! /bin/ksh
> #Note: for this test /pepe doesn't exist on machine1
> rsh machine1 "ls /pepe"
> echo $?
>
> In this case $? is 0 because the rsh executed succesfully.
> How can I get the result of the ls operation
>

Everybody seems to agree that using rsh it's not possible to get the
status
of the command directly, and some trick must be used:

1) Many suggested to use something like

variable=`rsh rmachine "command ; echo $status" `

or even

variable=`rsh rmachine "command || echo 'Error' "`

2) Other suggestion was to use ersh, and I got a copy of it.
I still didn't try it, but if anyone is interested, I can send it to
you.

3) A third option was to use
ssh (http://www/cs/hut.fi/ssh/#further-info)
or use
expect (http://expect.nist.gov, page 118 of the book Exploring
Expect).

I didn't try option nrs 2 and 3.
Since the I needed the output of the command to be redirected to a file,
what I did was:

rsh rmachine "command || echo ERROR in command" > myfile 2>&1
and grep for the string ERROR in myfile.

Thanks to all the repliers.

Stephen Harris <sweh@mpn.com>
"Garry D. Robbins" <Garry.Robbins@LABATT.com>
Claus Assmann <ca@informatik.uni-kiel.de>
Artur Shnayder <artur@compugen.co.il>
Matt Reynolds <reynolmd@aston.ac.uk>
Glenn Satchell - Uniq Professional Services <Glenn.Satchell@uniq.com.au>

vvuppa@unix.cis.state.mi.us (Vasu Vuppala (DCCI))
Drexx Laggui CSA <drexx@bancnet.net>
Roy Culley <tgdcuro1@gd2.swissptt.ch>
gibian@stars1.hanscom.af.mil (Marc S. Gibian)
Kevin.Sheehan@uniq.com.au (Kevin Sheehan {Consulting Poster Child})
Joseph S D Yao <jsdy@tux.org>
 0085P@VM1.CC.NPS.NAVY.MIL
charest@chou.CANR.Hydro.Qc.Ca (Claude Charest)
Jochen Bern <bern@TI.Uni-Trier.DE>
"Mike Salehi" <mrs@cadem.mc.xerox.com>

--
------------------------------------------------------------------------

Mariel Feder - I.T. Consultant unix.support@meralco.com.ph

Phone: (63) (2) 632.8862 / 632.8977 Fax: (63) (2) 632.8868

Meralco Electric Company Distributed Information Technology Team Manila - Philipines



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:11 CDT