Exit status of remote commands

Exit status of remote commands

Post by Al Starba » Wed, 12 Dec 2001 01:47:26



Hello All,

I've been trying to get the exit status of commands executed via rsh.
No matter what status the remote command exits with, rsh always exits
with a status of 0.  Is there a way to get rsh to report the status
that the remote command exits with?  If not, any ideas for a work
around?  Can ssh do this?

Thanks in advance for any help,

Al

 
 
 

Exit status of remote commands

Post by Guillaume Dargau » Wed, 12 Dec 2001 09:46:29


Quote:> I've been trying to get the exit status of commands executed via rsh.
> No matter what status the remote command exits with, rsh always exits
> with a status of 0.  Is there a way to get rsh to report the status
> that the remote command exits with?  If not, any ideas for a work
> around?  Can ssh do this?

Just tried it with ssh. Nope.

Workaround:

and parse the result for the number at the end...
--
Guillaume Dargaud
Colorado State University - Dept of Atmospheric Science
http://rome.atmos.colostate.edu/
  "A bachelor is a man who never makes the same mistake once."

 
 
 

Exit status of remote commands

Post by Martien Verbrugge » Wed, 12 Dec 2001 10:45:14


On Mon, 10 Dec 2001 17:46:29 -0700,

>> I've been trying to get the exit status of commands executed via rsh.
>> No matter what status the remote command exits with, rsh always exits
>> with a status of 0.  Is there a way to get rsh to report the status
>> that the remote command exits with?  If not, any ideas for a work
>> around?  Can ssh do this?

> Just tried it with ssh. Nope.

> Workaround:

> and parse the result for the number at the end...

That may depend on your version of ssh.

$ ssh -V
OpenSSH_2.9p2, SSH protocols 1.5/2.0, OpenSSL 0x0090602f
$ ls /foo
/bin/ls: /foo: No such file or directory
$ echo $?
1
$ ssh localhost ls /foo
ls: /foo: No such file or directory
$ echo $?
1
$ man ssh
[SNIP]
     The session terminates when the command or shell in on the remote machine
     exists and all X11 and TCP/IP connections have been closed.  The exit
     status of the remote program is returned as the exit status of ssh.
[SNIP]

Martien
--
                                |
Martien Verbruggen              | Can't say that it is, 'cause it
Trading Post Australia Pty Ltd  | ain't.
                                |

 
 
 

Exit status of remote commands

Post by Florian Stiass » Wed, 12 Dec 2001 17:35:30



Quote:>Hello All,

>I've been trying to get the exit status of commands executed via rsh.
>No matter what status the remote command exits with, rsh always exits
>with a status of 0.  Is there a way to get rsh to report the status
>that the remote command exits with?  If not, any ideas for a work
>around?  Can ssh do this?

RETCODE=`rsh host 'command ; echo $?'`

---
                        \|/
                        o o
 ___________________oOO_(_)_OOo______________________________________