2009/8/4 Peter Stuge <peter_at_stuge.se>:
> vti wrote:
>> >> How can I know when a program is executed when I do:
>> >>
>> >> libssh2_channel_open_session()
>> >> libssh2_channel_request_pty()
>> >> libssh2_channel_shell()
>> >> libssh2_channel_write(<my command>)
>> >>
>> >> ... wait while command is executing ...
>> >>
>> >> libssh2_channel_send_eof()
>> >> libssh2_channel_wait_eof()
>> >
>> > You must already know exactly how the device will behave.
>>
>> I am afraid I don't understand what you mean.
>
> Of course not. Sorry for the confusion!
>
>
>> Would you be so kind to clear what do you mean by 'device'?
>
> Never mind the device. My mind was on another mailing list. :)
>
>
>> I am using nonblocking version. Scp functionality works perfect.
>> But to make remote commands to work I have to do
>> sleep(<some empirical number>).
>
> RFC 4254 says to send SSH_MSG_CHANNEL_CLOSE. _channel_send_eof()
> should be used only internally in libssh2. Maybe also marked that
> way in the API somehow? Yes, might break ABI.
>
> Please try _channel_close() and _channel_wait_closed() instead.
I tried all that before writing to the list =/ No success.
I use
while (libssh2_channel_close(channel) == LIBSSH2_ERROR_EAGAIN);
while (libssh2_channel_wait_closed(channel) == LIBSSH2_ERROR_EAGAIN);
From the manual page:
libssh2_channel_close
Close an active data channel. In practice this means sending an
SSH_MSG_CLOSE packet to the remote host which serves as instruction
that no further data will be sent to it. The remote host may still
send data back until it sends its own close message in response. To
wait for the remote end to close its connection as well, follow
this command with libssh2_channel_wait_closed(3)
Is SSH_MSG_CLOSE is the same as SSH_MSG_CHANNEL_CLOSE?
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2009-08-04