EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Capturing stdout/stderr and sending stdin

Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.
Posted: 02/17/2012 07:51:38
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

I am using TElSimpleSSHClient to execute commands on another computer. I would like to be able to captures the stdout and stderr streams of that remote process and be able to send data to that process's stdin.

Looking at the documentation, it would appear that I need to use ElSubsystemSSHTunnel to achieve this, but it isn't clear how ElSubsystemSSHTunnel should be used. I've searched the website, but I couldn't find any additional information.

Could you provide a example for starting a process on the server using TElSimpleSSHClient and provides access to the stdin, stdout, and stderr streams of the started process?

Thank you,

Posted: 02/17/2012 10:50:24
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

Please refer to this article: http://www.eldos.com/documentation/sb...e_cmd.html

ElSimpleSSHClient.ReceiveData method described in the article has options for stderr handling.
Posted: 02/21/2012 08:51:12
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

Thank you for the reference. How do I handle sending stdin to the process on the server?
Posted: 02/21/2012 09:05:19
by Vsevolod Ievgiienko (EldoS Corp.)

TElSimpleSSHClient automatically sends its Command/Commands content to stdin after connection is established. If you need more flexible control then you can set ElSimpleSSHClient.RequestTerminal to 'true' before connection and then use ElSimpleSSHClient.Send* methods to send data to remote stdin.
Posted: 03/07/2012 15:09:14
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

Is it possible to read either stdout or stderr without disturbing the other stream's data?
Posted: 03/07/2012 15:54:41
by Eugene Mayevski (EldoS Corp.)

This is not possible via interface, though internally these are two independent data buffers. What is the reasoning for such requirement?

Sincerely yours
Eugene Mayevski
Posted: 03/07/2012 15:57:13
by Ken Ivanov (EldoS Corp.)

I am not quite sure about what exactly you meant by saying "disturbing". ReceiveData() and ReceiveText() methods of TElSimpleSSHClient class return chunks of data received from both stdout and stderr channels. If you do not need one of them, you can just ignore the corresponding chunk.
Posted: 03/08/2012 07:10:40
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

I would like to be able to access each of the standard streams as a System.IO.Stream. I have created a wrapper class that implements Stream to which I pass the instance of TElSimpleSSHClient being used to execute a command. Then when Read/Write is called on that wrapper stream, the appropriate SendData/ReceiveData calls are made on the SSH client. I have this working for stdin and stdout, but stderr is not working.

So, in some instances, a call will be made to read stdout, and then another call will be made to get the stderr; This is what I mean by not disturbing the other stream: I want stderr data to still be available after I read stdout, and vice versa.
Posted: 03/08/2012 07:39:16
by Eugene Mayevski (EldoS Corp.)

In your case it makes sense to pick all data and store them in your class (thus buffering them). So far it's the only option. Even if we decide to modify the class to make two separate methods (and here comes big IF), this will not happen before summer (when SBB 10 is released).

Sincerely yours
Eugene Mayevski
Posted: 03/08/2012 07:49:32
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

Buffering the data is what I was thinking, but I wanted to make sure that it wasn't possible the other way first.

Thank you
Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.



Topic viewed 3785 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!