I had a problem when the man page for 'ssh' says that it returns the exit code of the process that it starts, but I can not get it to return a non-zero error code. On the ssh man page:
The session terminates when the command or shell on the remote machine exits and all X11 and TCP/IP connections have been closed. The exit staβ tus of the remote program is returned as the exit status of ssh.
This is not true.
But I would try something like this and see what happens on your system.
% ssh localhost bash -c "exit 3" ; echo $? 0
When I run a similar command locally, bash returns the exit code.
% bash -c 'exit 3' ; echo $? 3
Double quotes will be removed before ssh displays the commands. So let's try more quotes.
% ssh localhost bash -c "'exit 3'" ; echo $? 3
Bingo. "Exit 3" turned into an "exit", followed by an ignored word on the bash command line. So bash ran the "exit" command.
Unfortunately for me, I think that this whole answer is a departure from the original questions and does not contain sufficient merit, since the question is by itself. So thank you all for helping me answer the second question (not related to the original question).
Chris quenelle
source share