Subject: Re: Libssh2 channel read issue using with pty request

Re: Libssh2 channel read issue using with pty request

From: Peter Stuge <peter_at_stuge.se>
Date: Sat, 8 Aug 2015 21:07:19 +0200

Kishore Av wrote:
> I using libssh2_channel_request_pty tried with asci, vanilla, vt-100
> terminal types.

Then your software must also implement correct and complete terminal
emulation for the type you request.

> After writing the data, I used looping to read data

Terminals aren't so simple, and a pty channel will be running a shell
intended for communication with humans and not with a program such as
yours.

It is extremely fragile and error-prone to try to automate anything
around an interactive shell. Use a dedicated server-side process and
protocol instead.

> actual data size is 68kb, but it reads 10240 bytes.

Can you verify that this happens also by modifying the example/ssh2.c
program in the libssh2 source tree?

> For some commands, I'm not getting any read response as i getting
> when i execute manually.

When you execute "manually" the terminal emulation code path is
*significantly* different, that can not be compared with raw write to
a pty.

> Can any one suggest me the idea how i need to implement this problem.

For a reliable solution you need to have a special program (either
custom-made or a standard one but one which is made to explicitly
support automation) running on the server side, and communicate with
that software using a custom or a standard protocol, also one that is
made for automation of the tasks and actions that you want to automate.

//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2015-08-08