SUMMARY: rsh Question

From: Jason Keltz (cs911089@red.ariel.cs.yorku.ca)
Date: Tue Nov 19 1996 - 11:58:22 CST


Summary of my original question:

rsh returns the error status of rsh and not of the command that is executed.
I need the return status of the executed command. Any way to do this?

I received quite a large response from people which I am incredibly impressed
with. You've heard it all before, but here are the people that took the time
out of their busy days to give me a hand, and I *really* *really* appreciate
it.

Jeff Popp <popp@luey.redars.ca.boeing.com>
Claus Assmann <ca@informatik.uni-kiel.de>
Kris Briscoe <hxktb0@svho1nfs_1.supervalu.com>
Mark Bergman <bergman@phri.nyu.edu>
Martin Achilli <martin@mednuc.hsr.it>
Rich Kulawiec <rsk@itw.com>
Robert Jennings <rjenning@informix.com>
Colin Matthews <cybcpm@cyber.reading.ac.uk>
Reggie Stuart <Reggie_Stuart_at_~ISTG2__PO@smtpinet.aspensys.com>
Mattias Zhabinskiy <mattias@txc.com>
Colin J. Wynne <cwynne@mts.jhu.edu>
Jos van Wezel <wezel@bio.vu.nl>
Jason Noorman <jasonn@nabaus.com.au>
Brian Desmond <brian@chimera.psych.unimelb.edu.au>
Brion Leary <bleary@state.ma.us>
Brett Lymn <blymn@awadi.com.au>

The responses are summarized below:

1) No need to write a backup script. I'll give you mine!
   [I wish I had known that there so many generous people out there before
    I started working on my own backup script. I finished mine, so I don't
    think I'm going to put it on the backburner now, but it certainly doesn't
    hurt to look at other peoples scripts to see how they do things. This is
    the best way to learn! As a side note, I and am going to make my own
    backup system available to anyone who wants it once I correct this rsh
    error which should be shortly since I received so many responses!]
2) I was provided with a script called "ersh" written in 1991 by
   Maarten Litmaath.
   [This script calls rsh itself, and returns the exit status of the
    command. I have to look at it in more detail to see how it's doing it
    though. It does work. I tried it.]
3) Don't try to extract info from rsh. Use logger instead.
   [I'd like to look at this solution in more detail.]
4) Wrap the calling command in a shell script that echoes $? at the end
   (the exit status under sh). This means that you can now do:
   exit_status=`rsh <machine> <script>' and exit_status will contain the
   exit status of <script>. One suggestion was to redirect all output of
   the command to /dev/null so that there is only one item output. Another
   suggestion was to simply grab the last line of output (the exit status)
   using tail or a similar method. Yet another suggestion was to use a two
   way pipe, waiting for the command to exit, and then checking its status.
   [All of these seem to work. I tried them all out.]
5) I was told that rsh wants to return two different values - its own status
   is in the first 8 bits of the return value, and the exit status of the
   command is in the next 8 bits. So, for example, in C, you could shift the
   status 8 bits (status>>8) and get the return status of the command.
   [I tried this, and unfortunately, it did not work for me. The status
    shifted 8 bits always seemed to return the identical rsh status.]
6) Use a file to do logging of the output status of rsh. It was also
   suggested that the file could be analyzed to determine other dump errors.
7) Use the remote tape protocol, specifying host:device.
   [I do do this, but to backup remote systems, we need to rsh to the system
    first, and then use the remote tape protocol to use the tape drive on
    the originating system.]
8) Use ssh which exits with the exit code of the remote comand.
   [I haven't tried this, but it sounds similar to ersh.]

Once again, thanks not only to everyone who helped me specifically for their
help, but thanks also to those who help lots of people on this list every day.

Jason Keltz
jas@cs.yorku.ca



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