Subject: Re: Hacking rsh to add exit codes.
To: Todd Whitesel <>
From: Brian Stark <>
List: tech-userlevel
Date: 01/13/2000 10:22:51
On Thu, 13 Jan 2000, Todd Whitesel wrote:

> What lessons are out there that I should listen to before deciding to go
> ahead with this?

Hi Todd,

It sounds like it is possible to modify the code to do what you want, but
I have found a simpler way. Maybe it will work for you.

I simply execute rsh and pipe the output to "wc -l" on the remote server.

Here's an example: If I want to execute the date command on a remote
server I can do this:

  rsh porter date 

If I want to know if the command was successful I can do this:

  if [ `rsh porter "date | wc -l"` != 0 ]; then
    echo "oh no!"
    echo "command was successful"

Here is what this method looks like when executing:

  possum:bstark$ rsh porter date 
  Thu Jan 13 09:51:47 CST 2000
  possum:bstark$ rsh porter "date | wc -l"
  possum:bstark$ rsh porter "date2 | wc -l"
  ksh: date2:  not found.

This trick relies on the fact that date will send output to stdout (thus
providing input to wc), and error messages to stderr (not read by wc). 


| Brian Stark                       | Internet : |
| Siemens PT&D, Inc.                | Voice    : +1 612 536-4697        |
| Power Systems Control Division    | Fax      : +1 612 536-4919        |
| 7225 Northland Drive, Brooklyn Park, Minnesota 55428   USA            |