EldoS | Feel safer!

Software components for data protection, secure storage and transfer

ElSimpleSSHClient Commands property

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.
#19527
Posted: 03/19/2012 13:27:10
by Mohamed Koker (Priority Standard support level)
Joined: 01/22/2008
Posts: 18

Thanks Eugene!

I think the PerformSendRecv will probably work best for me.

Can you suggest an easy way to detect when the response is complete?

Regards

-Mohamed
#19529
Posted: 03/19/2012 14:11:20
by Eugene Mayevski (EldoS Corp.)

Unfortunately, as shell is human-oriented, there's no easy way to determine the end of certain output. Prompt is a good indicator and separator but only when you know it ahead or can reliably guess it from the initial output. Eg. when you login interactively, you get some welcome text followed by the prompt. In general, prompt will be the last received line, but then how do we determine what "the last" is? No data from the remote side for say 3 seconds can be more or less reliable indicator, but it's not very good for automated scripts.


Sincerely yours
Eugene Mayevski
#19530
Posted: 03/19/2012 14:18:52
by Eugene Mayevski (EldoS Corp.)

In PerformRecvSend I wrote about I've missed the call to SendData() before while() loop.


Sincerely yours
Eugene Mayevski
#19534
Posted: 03/19/2012 21:59:34
by Mohamed Koker (Priority Standard support level)
Joined: 01/22/2008
Posts: 18

Hi Eugene,

I have tried to implement the PerformSendRecv method but the requirement to use the timer is throwing off my best efforts to do so.

My goal in this particular case is for this method to be blocking since I have no idea how long individual commands are going to take to complete.

I can take care of updating the GUI to keep my users informed that a lengthy operation is taking place so all I really need is a blocking version of PerformSendRecv.

My server does not send messages to the client, it only responds to commands from the client so some of the concerns you have mentioned before regarding the nature of the SSH protocol simply do not apply in my case.

I would really appreciate your help with some actual code that does this instead of pseudo-code.

Thanks in advance

-Mohamed
#19535
Posted: 03/19/2012 23:21:13
by Eugene Mayevski (EldoS Corp.)

The code snippet I provided is blocking and doesn't need a time. PerformRecvSend will send the command and return only after either the response is received or connection is closed prematurely.

In Win32 programming you could also insert GetMessage/DispatchMessage method calls into PerformRecvSend, but AFAIK this doesn't work this way in .NET.


Sincerely yours
Eugene Mayevski
#19536
Posted: 03/19/2012 23:42:38
by Mohamed Koker (Priority Standard support level)
Joined: 01/22/2008
Posts: 18

Thanks Eugene!

I think I get it now.

The problem I had earlier was that in one case, my loop was terminating too early i.e. before the server had sent the complete response.

I really appreciate your help in working through this issue.

Regards

-Mohamed
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

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