Hi,
I'm working on NETCONF protocol implementation, which uses SSH as
transport layer. I make some testing around libssh2. I tried to use
standard command execution, shell execution and my own SSH subsystem.

I have lot of problems with shell, similar to yours. Finally I have
used separate reading thread, which reads data out of the SSH channel
in loop and separate write thread, which writes characters typed by
user. It solved everything.

I think, main problem is, that you don't know how long the server
response is. For example NETCONF over SSH solves it by defining a
special character sequence to recognize end of the NETCONF message, so
you can read, until you recognize it. But you can't determine when
output of the shell command ends exactly.

When you use separate thread for reading, you can easily read
everything that arrives from channel, when it arrives, until EOF is
read (meaning shell was closed).

I hope this idea will help

Marek Zizlavsky
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Reply via email to