SSH remote command execution 'exit status 255' - SSH

This is a discussion on SSH remote command execution 'exit status 255' - SSH ; Hi all, I've got a question dealing with remote execution of commands through ssh. 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 ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: SSH remote command execution 'exit status 255'

  1. SSH remote command execution 'exit status 255'

    Hi all,

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

    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 ?

    Thanks,

  2. Re: SSH remote command execution 'exit status 255'

    wrote:
    > 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 ?


    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!
    When do we want it? ABJ!

+ Reply to Thread