Re: Get exit code of a executed remote command
- Subject: Re: Get exit code of a executed remote command
- From: "Oliver Stöneberg" <oliverst@xxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Reply-to: oliverst@xxxxxxxxx
- Date: Tue, 02 Aug 2011 16:27:52 +0200
- To: libssh@xxxxxxxxxx
The function is quite flakey, because of issue in the way the close
flag is handled internally. I had to do two things:
1. call ssh_channel_close() before you call
2. put ssh_channel_get_exit_status() in a loop and wait for the
result to be not -1. I am waiting 20 times 50ms.
This have been very reliable in using it with dozens, maybe even
hundreds or thousands of machines in the past few months.
As a side note, you might also run into this problem with buggy SSH
daemons. There was apparently a dropbear version, that didn't always
send the exit status.
> I tried to run a command on a remote host via "ssh_channel_request_exec"
> and get the the exit code back. My problem is that
> "ssh_channel_get_exit_status" returns always -1.
> Any idea what I'm doing wrong?
> Thanks in advance,
Archive administrator: email@example.com