exit status of ssh?

Peter Stuge peter at stuge.se
Tue Mar 22 05:53:05 EST 2011


Chris Quenelle wrote:
> cryo gives the same result as on the ssh-originating host:
> % ssh cryo
> % bash -c '"/bin/ls /foo"' ; echo $?

Note that this command is really bogus. You are asking bash to
execute the command "/bin/ls /foo"  ie. the program foo, in a
subdirectory called l-s-space, in /bin.


> bash: /bin/ls /foo: No such file or directory
> 127

But regardless what the error is, I think you should be getting back
the error code.

$ bash -c '/bin/ls /foo'; echo $?
/bin/ls: cannot access /foo: No such file or directory
2
$ bash -c '"/bin/ls /foo"'; echo $?
bash: /bin/ls /foo: No such file or directory
127
$ ssh localhost '/bin/ls /foo'; echo $?
/bin/ls: cannot access /foo: No such file or directory
2
$ ssh root '"/bin/ls /foo"'; echo $?
bash: /bin/ls /foo: No such file or directory
127


> So by reading between the lines, I assume that other
> people are not seeing this kind of behavior?

As you can see above it all works as expected here.


//Peter


More information about the openssh-unix-dev mailing list