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?

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.

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.

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.

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).

We use cookies to help provide you with the best possible online experience. By using this site, you agree that we may store and access cookies on your device. You can find out more about and set your own preferences here.