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.
#19358
Posted: 03/08/2012 09:06:38
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

How do you tell when you have reached the end of the stream with ReceiveData?
#19361
Posted: 03/08/2012 09:22:02
by Eugene Mayevski (EldoS Corp.)

ReceiveData method returns when there's something to return (i.e. it blocks until there's data to return). If the connection is closed while waiting for data, the exception will be thrown. There's no way to say "this is the end of the data" as the server can send new data at any moment of time (until connection is closed, of course).


Sincerely yours
Eugene Mayevski
#19363
Posted: 03/08/2012 09:44:43
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

How can you tell when a process you start is complete?

Looking at the documentation for Command, I noticed:
Quote
When the command is not set, Shell tunnel is created and the application can send several commands (via shell).


I was under the impression that you could only run commands using the Command or Commands properties. Can you use SendData to start commands on on open connection?
#19365
Posted: 03/08/2012 09:57:05
by Eugene Mayevski (EldoS Corp.)

If you open shell connection, you get namely shell (the same you see on the screen when connecting when ssh client). In shell you have to parse what you get and guess the end of the command probably by finding shell prompt.

Shell channel is not well suited for execution of multiple commands as this is a human-oriented method of access.


Sincerely yours
Eugene Mayevski
#19373
Posted: 03/08/2012 11:55:06
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

If you are using Command, how can you tell when the process has completed?
#19376
Posted: 03/08/2012 12:10:30
by Eugene Mayevski (EldoS Corp.)

Connection will be closed automatically upon completion.


Sincerely yours
Eugene Mayevski
#19377
Posted: 03/08/2012 13:13:02
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

What might keep the connection open after the command has completed?

I am executing a simple command on a Linux computer to write to stderr (echo blah >&2). For some reason the output of that command is appearing in the stdout buffer returned from ReceiveData. My test is hanging because OnCloseConnection is never fired and my streams are not closed.
#19378
Posted: 03/08/2012 13:19:46
by Eugene Mayevski (EldoS Corp.)

Please post your test to HelpDesk for checking. Be sure to include all needed source files.


Sincerely yours
Eugene Mayevski
#19379
Posted: 03/08/2012 14:32:20
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

I have posted my code and tests.
#19391
Posted: 03/09/2012 15:03:34
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

My issue can be replicated using the SimpleSSHClient demo as well.

Set a breakpoint after client.ReceiveData in SimpleSSHDemo.frmMain.timer_Tick. If you send an invalid command, such as "NoSuchCommand", you get first get:
Quote
NoSuchCommand\r\n
in data, which is what was sent, then you get:
Quote
NoSuchCommand: command not found
tester@ubuntu:~$
tester@ubuntu:~$

The first line should be in dataErr, and the rest does belong in stdout.

Can you provide an example where dataErrLen will be non-zero in this demo?
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 3623 times

Number of guests: 4, 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!