EldoS | Feel safer!

Software components for data protection, secure storage and transfer

TElSSHClient reading process stdin stdout and stderr

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#19835
Posted: 04/18/2012 13:22:18
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

Are there any examples for executing a command using TElSSHClient and reading its stdout and stderr and writing to its stdin? I see that TElCommandSSHTunnel is used for remote execution of commands, but I don't see SendData/ReceiveData equivalents.
#19836
Posted: 04/18/2012 13:46:22
by Eugene Mayevski (EldoS Corp.)

Check ShellTunnel instead. Check SophisticatedSSHClient sample in in Samples\<language>\SSHBlackbox\Client folder.

On a side note you've been using SecureBlackbox for quite a long time. You are welcome to consider purchasing a license.


Sincerely yours
Eugene Mayevski
#19838
Posted: 04/18/2012 14:23:21
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

OK, so using ElSSHTunnelConnection, the OnData event is fired when there is data from stdout, and OnExtendedData is fired when there is data from stderr and data can be written to sdtin using SendData. Is this correct?

When would you use TElCommandSSHTunnel instead of TElShellTunnel?

I am still evaluating SecureBlackBox (my evaluation license runs out in the middle of May). I believe that once I have things implemented and tested using TElSSHClient rather than TElSimpleSSHClient, we will be ready to purchase licenses for SecureBlackBox.

Thank you,

Andy
#19839
Posted: 04/18/2012 14:44:59
by Eugene Mayevski (EldoS Corp.)

Quote
Andy Gardner wrote:
OK, so using ElSSHTunnelConnection, the OnData event is fired when there is data from stdout, and OnExtendedData is fired when there is data from stderr and data can be written to sdtin using SendData. Is this correct?


Yes, data is passed via events.

Quote
Andy Gardner wrote:
When would you use TElCommandSSHTunnel instead of TElShellTunnel?


When you'd use Command or Commands property in TElSimpleSSHClient . In this case TElSimpleSSHClient internally uses TElCommandSSHTunnel instead of TElShellSSHTunnel.


Sincerely yours
Eugene Mayevski
#19987
Posted: 05/01/2012 08:19:36
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

I have altered the Sophisticated SSH client to connect the SSH client, then execute a command using TElCommandSSHTunnel. The command executes correctly, and I get stdout. However, when I run a command that errors, the stderr is coming in on sshTunnelConnection_OnData rather than on sshTunnelConnection_OnExtendedData as I would expect.

Looking at the documentation for TElSSHTunnelConnection.OnExtendedData, I see a note saying:
Quote
you can not use this event directly. Use TElSSHTunnelConnectionList.OnExtendedData event instead.

But that only applies to ActiveX, correct? I am using C#.

Is there a setting I need to alter to be able to get stderr in the OnExtendedData handler?
#19988
Posted: 05/01/2012 08:27:10
by Ken Ivanov (EldoS Corp.)

This means that either the remote program outputs error-related information to STDOUT, or the SSH server joins both OUT and ERR streams together and returns everything through the OUT stream.

Did you try doing the same with the shell tunnel, is the data-that-is-supposed-to-come-from-STDERR returned through the STDOUT channel as well?
#19989
Posted: 05/01/2012 09:05:30
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

The remote program isn't outputting error-related information to stdout. I wrote a simple bash script to write to stdout and stderr:
Code
echo stdout
echo stderr >&2

So I know that the command being executed is writing to stderr.

I'm pretty sure that it isn't the SSH server, because I was able to get stderr using TElSimpleSSHClient, and I haven't changed the server.

I did a small modification to my test to use TElShellSSHTunnel rather than TElCommandSSHTunnel, and the stderr data still comes to OnData rather than OnExtendedData.

I believe I had a similar problem with TElSimpleSSHClient initially because I had the RequestTerminal property set incorrectly, but I don't see a similar property for TElSSHClient.
#19990
Posted: 05/01/2012 09:13:39
by Ken Ivanov (EldoS Corp.)

Right, the RequestTerminal property set to wrong value may also lead to the issue. This property is exposed by tunnel components (TElCommandSSHTunnel and TElShellSSHTunnel), not by TElSSHClient, so you can configure it there.
#19992
Posted: 05/01/2012 10:31:29
by Eugene Mayevski (EldoS Corp.)

Quote
Andy Gardner wrote:
The remote program isn't outputting error-related information to stdout. I wrote a simple bash script to write to stdout and stderr:


Last time you asked this question we have figured out that your server mixed stdout and stderr. Did anything change since then?


Sincerely yours
Eugene Mayevski
#19998
Posted: 05/01/2012 13:56:00
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

When I asked before, it was related to TElSimpleSSHClient, and it turned out that the server was configured correctly, but that I had misunderstood how RequestTerminal should be set. When I set RequestTerminal to false, it worked correctly. I didn't know where RequestTerminal was located for TElSSHClient.

Thank you, Innokentiy, I set RequestTerminal to false on the tunnel, and I started getting stderr in OnExtendedData.
Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.

Reply

Statistics

Topic viewed 1389 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!