• Remote Command execution exit-status is always 0

    From William Unruh@21:1/5 to Dhanasekaran Anbalagan on Tue Apr 23 16:55:50 2019
    On 2019-04-23, Dhanasekaran Anbalagan <bugcy013@gmail.com> wrote:
    Hi Guys,

    Currently, we are connecting windows machines via OpenSSH.

    When we execute the remote command it always returns exits status 0


    console output for ref.

    =====================
    [rd@dvserver143 dhana]$ ssh dvdev@10.10.1.216 'hostname'
    WIN-7U3C8GAPDJI
    [rd@dvserver143 dhana]$ echo $?

    The command you ran was ssh. It succeeded. This will not tell you what
    the exit status is of the remote command.
    You have to do that as part of the remote command.


    0
    [rd@dvserver143 dhana]$ ssh dvdev@10.10.1.216 'hostname1'
    /bin/sh: hostname1: command not found
    [rd@dvserver143 dhana]$ echo $?
    0
    [rd@dvserver143 dhana]$
    =====================

    please guide me. How to fix this.

    ask the remote machine what the exit status was of the command you ran.
    I have no idea if Windows will give you an exit status or not.


    Regards
    -Dhanasekaran.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dhanasekaran Anbalagan@21:1/5 to All on Tue Apr 23 09:39:41 2019
    Hi Guys,

    Currently, we are connecting windows machines via OpenSSH.

    When we execute the remote command it always returns exits status 0


    console output for ref.

    =====================
    [rd@dvserver143 dhana]$ ssh dvdev@10.10.1.216 'hostname'
    WIN-7U3C8GAPDJI
    [rd@dvserver143 dhana]$ echo $?
    0
    [rd@dvserver143 dhana]$ ssh dvdev@10.10.1.216 'hostname1'
    /bin/sh: hostname1: command not found
    [rd@dvserver143 dhana]$ echo $?
    0
    [rd@dvserver143 dhana]$
    =====================

    please guide me. How to fix this.

    Regards
    -Dhanasekaran.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dhanasekaran Anbalagan@21:1/5 to All on Tue Apr 23 11:01:24 2019
    Hi William,

    The same command When I execute linux machine. I am able to get the exit-status properly.

    console print for linux machine.
    ==================
    [rd@dvserver143 ~]$ ssh tauqa@10.40.51.22 "hostname"
    dvserver22
    [rd@dvserver143 ~]$ echo $?
    0
    [rd@dvserver143 ~]$ ssh tauqa@10.40.51.22 "hostname1"
    bash: hostname1: command not found
    [rd@dvserver143 ~]$ echo $?
    127
    [rd@dvserver143 ~]$
    ==================

    so. the issue is the windows+opensshd is not properly returning the exit status code.

    The command you ran was ssh. It succeeded. This will not tell you what
    the exit status is of the remote command.
    You have to do that as part of the remote command.


    0
    [rd@dvserver143 dhana]$ ssh dvdev@10.10.1.216 'hostname1'
    /bin/sh: hostname1: command not found
    [rd@dvserver143 dhana]$ echo $?
    0
    [rd@dvserver143 dhana]$
    =====================

    please guide me. How to fix this.

    ask the remote machine what the exit status was of the command you ran.
    I have no idea if Windows will give you an exit status or not.


    Regards
    -Dhanasekaran.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Grant Taylor@21:1/5 to Dhanasekaran Anbalagan on Tue Apr 23 20:50:08 2019
    On 4/23/19 12:01 PM, Dhanasekaran Anbalagan wrote:
    The same command When I execute linux machine. I am able to get the exit-status properly.

    The testing I just did (Linux to Linux) agrees with this.

    so. the issue is the windows+opensshd is not properly returning the exit status code.

    I wonder if this has anything to do with the difference in exist status
    vs ERRORLEVEL. As in if this is a Windows<ism> (formerly a DOS<ism>)
    that isn't translating well.



    --
    Grant. . . .
    unix || die

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From William Unruh@21:1/5 to Grant Taylor on Wed Apr 24 03:23:19 2019
    On 2019-04-24, Grant Taylor <gtaylor@tnetconsulting.net> wrote:
    On 4/23/19 12:01 PM, Dhanasekaran Anbalagan wrote:
    The same command When I execute linux machine. I am able to get the
    exit-status properly.

    The testing I just did (Linux to Linux) agrees with this.

    so. the issue is the windows+opensshd is not properly returning the exit
    status code.

    I wonder if this has anything to do with the difference in exist status
    vs ERRORLEVEL. As in if this is a Windows<ism> (formerly a DOS<ism>)
    that isn't translating well.

    The man page says that ssh returns with the exit code of the command ssh
    runs, unlike my statement originally. But I have no idea what "exit
    satus" means under Windows. What is the ssh server program on the other
    end?





    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Keith Thompson@21:1/5 to Dhanasekaran Anbalagan on Thu May 2 18:12:56 2019
    Dhanasekaran Anbalagan <bugcy013@gmail.com> writes:
    Currently, we are connecting windows machines via OpenSSH.

    When we execute the remote command it always returns exits status 0


    console output for ref.

    =====================
    [rd@dvserver143 dhana]$ ssh dvdev@10.10.1.216 'hostname'
    WIN-7U3C8GAPDJI
    [rd@dvserver143 dhana]$ echo $?
    0
    [rd@dvserver143 dhana]$ ssh dvdev@10.10.1.216 'hostname1'
    /bin/sh: hostname1: command not found
    [rd@dvserver143 dhana]$ echo $?
    0
    [rd@dvserver143 dhana]$
    =====================

    please guide me. How to fix this.

    How are you running OpenSSH on Windows? You clearly have some UNIX-like
    layer on top of Windows, given the reference to "/bin/sh" in the error
    message -- but which one?

    For example, "eddie" is my Windows 10 laptop, with sshd running under
    64-bit Cygwin. I'm invoking ssh from my Ubuntu system.

    $ ssh eddie true ; echo $?
    0
    $ ssh eddie false ; echo $?
    1
    $ ssh eddie nosuchcommand ; echo $?
    bash: nosuchcommand: command not found
    127
    $

    (The reference to "bash" is probably because that's my login shell on
    eddie.)

    --
    Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> Will write code for food.
    void Void(void) { Void(); } /* The recursive call of the void */

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)