Subject: Re: SSH client is not reading full data if executed command generates big output

Re: SSH client is not reading full data if executed command generates big output

From: Subrata Dasgupta <subrata_usha_at_rediffmail.com>
Date: 28 Oct 2018 19:16:06 -0000

Hi Peter ,Many thanks for your explanation.My intention is to run multiple commands sequentially over ssh and get the output.It seems &quot;libssh2_channel_exec&quot; function can only execute a single command over a session or channel. So this option will not serve my purpose because commands may have some sub-commands. So I need to retain the session or channel to execute those sub-commands. Please let me know if my understanding is wrong and kindly let me know how to execute multiple commands and sub-commands over libssh2_channel_exec.It seems only &quot;libssh2_channel_shell&quot; function can serve my purpose because I can execute multiple commands on a established channel / session. Please let me know if I am wrong.It also seems from the different ssh tutorials from net that non-interactive session may serve my purpose because there is no pty associated with the channel. So I have tried to comment out the &quot;libssh2_channel_request_pty&quot; call , but unfortunately result is the same(server do not
send all data). What could be the reason of such problem and how to fix it if possible ?Lastly is there anyway to get all output data of commands or sub-commands without using terminal emulation ?? Please advice if possible.Thanks a lot again,SubrataFrom: Peter Stuge &lt;peter_at_stuge.se&gt;Sent: Sun, 28 Oct 2018 04:57:16To: libssh2-devel_at_cool.haxx.seSubject: Re: SSH client is not reading full data if executed command generates big outputYour attached example requests a VT100 pseudo-terminal (pty) from theserver, but does not include any terminal emulation whatsoever. Thatwill never work reliably in the general case.PuTTY includes significant terminal emulation code. Linux/Unix systemsalways have a terminal emulator. Windows never does.Subrata Dasgupta wrote:&gt; But when output of the remotely executed program is very big then&gt; the client is not able to read all the data. Seems server is sending&gt; the partial data and then the command prompt.In other words: Without terminal emulation, communication is un
reliable.&gt; But if I connect the same server using PUTTY and execute the same&gt; command then PUTTY terminal is showing &amp;quot;more&amp;quot; at the end&gt; of terminal and wait for my &amp;quot;return&amp;quot; key press.In other words: With terminal emulation, communication is reliable.&gt; My objective is to read all the output of the command without blocking&gt; on &amp;quot;more&amp;quot; ( means &amp;quot;return&amp;quot; key press).&gt; How can I achieve this ?It depends on the capabilities of your server system, but quitelikely you will need to implement some if not full terminal emulationand then you may have to make your program recognize the &quot;more&quot; prompt,and then simulate a human pressing &quot;return&quot;, while also filteringthat out of the data stream that you want to scrape.If you&#39;re lucky then the server also supports a non-interactive terminaltype, where you can scrape all output without interaction. That&#39;s allcompletely out of scope of the SSH protocol and thus lib
ssh2, it isexclusively a property of your particular server. You can try using&quot;raw&quot;, &quot;ascii&quot; and maybe some others instead of &quot;vt100&quot; in the example -whatever your research on that topic finds may be worth a try.I will recommend to search for an API offered by the server productto do what you want instead of trying to automate around theinteractive interface.Good luck.//Peter_______________________________________________libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

_______________________________________________
libssh2-devel https://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2018-10-28