[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Get exit code of a executed remote command
[Thread Prev] | [Thread Next]
- 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: Wed, 03 Aug 2011 09:46:25 +0200
- To: libssh@xxxxxxxxxx
Hi Thomas, I think you actually need both. ssh_channel_send_eof() signals the server, that you are done sending data and ssh_channel_close() signals, that you are closing the channel. The latter one imply the first one, but I am not sure. I also just remembered, that you will get -1 as long as you dind't send the EOF yet. Greetings Oliver > Hi Oliver, > > that seems to work, thanks a lot for your help! > By the way I figured out that ssh_channel_send_eof() instead of > ssh_channel_close() also works. > > > Regards, > > Thomas > > > 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 > > ssh_channel_get_exit_status() > > 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. > > > >> Hi, > >> > >> 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, > >> > >> Thomas > >> > > > > > > > >
Get exit code of a executed remote command | Thomas Mayer <tm.telemotive@xxxxxx> |
Re: Get exit code of a executed remote command | "Oliver Stöneberg" <oliverst@xxxxxxxxx> |
Re: Get exit code of a executed remote command | Thomas Mayer <tm.telemotive@xxxxxx> |