EldoS | Feel safer!

Software components for data protection, secure storage and transfer

"SSH connection already established" error

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.
#19173
Posted: 02/22/2012 08:13:11
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

I want to connect to a computer, query the file system and run various commands. At the moment, I am using multiple connections to achieve this (initial connection, an SFTP connection for the file system, and one for each set of command that I want to execute), but when I attempt to make another connection to execute a command, I get an exception saying "SSH connection already established".

Is it possible to have multiple connections to the same computer using SSHBlackBox? The server can handle it because I am able to connect with multiple PuTTY sessions.

Is this the proper way to do what I want, or is there a way to pass an already established connection to SFTP and to capture stdin, stdout and stderr without creating a new connection and using the Command or Commands properties?

Thank you,

Andy
#19174
Posted: 02/22/2012 08:26:44
by Vsevolod Ievgiienko (EldoS Corp.)

Do you call Open method more than once for one instance of ElSimpleSSHClient? You should call Close for each Open or use ElSimpleSSHClient.ExecuteCommand method.
#19175
Posted: 02/22/2012 09:15:38
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

I am creating multiple instances of ElSimpleSSHClient, so I am only calling Open once per instance. Is it possible to use ExecuteCommand and capture stdout and stderr and send data to stdin?
#19176
Posted: 02/22/2012 09:21:10
by Vsevolod Ievgiienko (EldoS Corp.)

Quote
Is it possible to use ExecuteCommand and capture stdout and stderr and send data to stdin?

Code
byte[] ExecuteCommand(string Cmd, ref byte[] StdErrData);
function ExecuteCommand(const Cmd: string; var StdErrData As Byte()): BufferType;
method sends Cmd to stdin, returns stdout and writes stderr to StdErrData.
#19177
Posted: 02/22/2012 09:22:30
by Vsevolod Ievgiienko (EldoS Corp.)

Quote
I am creating multiple instances of ElSimpleSSHClient, so I am only calling Open once per instance.

Then its strange that you get "SSH connection already established" exception. Could you post a code sample.
#19178
Posted: 02/22/2012 09:23:48
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

OK, so if I wanted to start a process then send information to that process's stdin, I would call ExecuteCommand twice?
#19179
Posted: 02/22/2012 09:26:08
by Vsevolod Ievgiienko (EldoS Corp.)

Yes exactly. Please note, that you should not call Open/SendData/ReceiveData/Close methods of the component if ExecuteCommand is used, as the method performs all the necessary calls internally.
#19180
Posted: 02/22/2012 09:52:31
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

Thanks for the information. I will re-write my classes to use ExecuteCommand, and get back to you if I have more trouble.
#19181
Posted: 02/22/2012 10:02:42
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

I forgot about SFTP. Is it possible to create an SFTP connection using an existing SSH connection?
#19182
Posted: 02/22/2012 11:14:18
by Eugene Mayevski (EldoS Corp.)

Not with TElSimpleSSHClient.

When you use TElSSHClient class, you can open SFTP subsystem. TElSSHClient is a sophisticated component which, however, requires quite a lot of work to do everything right.


Sincerely yours
Eugene Mayevski
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.

Reply

Statistics

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