SSH remote command execution 'exit status 255'

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi all,

I've got a question dealing with remote execution of commands through

Executing a command locally on a Unix box, the $? in the shell gives
me the exit status of the command.
Moreover, if the command (instead of exiting normally) is killed by a
signal, examinig $? let me know
that the command was killed and by which signal.

For example sending a kill -9 to the command, $? is set to 137.
WIFSIGNAL(137) is true and WTERMSIG(137) gives 9 which is exactly the
signal number I sent to the program.

Now if I execute the command on a remote sshd server with an ssh
client command, after ssh command terminates,
$? reflects the exit status of the remotely executed command if that
command exited normally.

However, if the remote command was killed by a signal, after ssh
command terminates, $? is always 255 which
does not reflect what has going on on the remote server and is not
very useful.

So my question is : is it possible to get the actual remote command
exit status even when the command was killed;
and if so, how to get it ?


Re: SSH remote command execution 'exit status 255'

Quoted text here. Click to load it

That information is transmitted through the SSH protocol to the
client; it's then up to the client software to decide what if
anything to do with it.

PuTTY's command-line counterpart Plink handles a remote signal exit
by returning 128 plus the signal number, following the common Unix
tradition for what to do if you're trying to pass an exit code back
from a child process that died of a signal.
Simon Tatham         What do we want?        ROT13!

Site Timeline