receive output - WeOnlyDo Discussion board

receive output (wodSSH / wodSSH.NET)

by ganesh sankpal, Wednesday, August 06, 2014, 16:44 (1202 days ago)

Hello,

I am using wodssh com dll in VC++ application to execute commands on remote machines.
I am able to execute the command but have no idea about how to get the output returned by the command in my program memaory using VC++.
I came across the Receive method of wodssh but can anyone guide me on how can I use that method or event to get the output returned by the command in the memory.

Thanks & Regards,
GaneshS

receive output

by wodSupport, Wednesday, August 06, 2014, 19:58 (1201 days ago) @ ganesh sankpal

Ganesh

hi. Did you check out samples that come with wodSSH? There are VC samples that use Receive method. You could use it in blocking mode to wait for data, or you can use it in Received event when wodSSH notifies you that data is arriving.

Note that Receive will return whatever was in incoming buffer up to the point you called it - which is perhaps not (all) you have expected to receive.

Kreso

receive output

by ganesh sankpal, Thursday, August 07, 2014, 16:12 (1201 days ago) @ wodSupport

Hello Kreso,

I got the solution on my problem yesterday itself after posting this issue :-).

But now I am facing some different problem. I try to execute a command on remote MAC machine but to execute that command it require root permission thats why it ask for password. I could successfully provide the password too, but after providing a password output I could print the output on console but when I am using receive method to get the output in program memory it didn't work. Timeout occurred.

As per wodssh documentation, I can use multiple Receive method in the program.
Can you help me on how to get the output in this case.

Thanks & Regards,
GaneshS

receive output

by wodSupport, Thursday, August 07, 2014, 19:25 (1200 days ago) @ ganesh sankpal

Ganesh,

hi. I doubt this is related to getting root privileges. Receive doesn't return if there's nothing to be returned. What exactly did arrive, and what are you expecting to arrive? Did you send CRLF's after sending commands or root password? Perhaps remote side is still expecting something.

Kreso

receive output

by Ganesh Sankpal, Thursday, August 28, 2014, 10:51 (1180 days ago) @ wodSupport

Hello,

I got solutions for all my previous problems. Now it seems to be working fine. :-)

Though I need some information, can I generate a public key using WODKey library methods? I used Generate method which generates the private key for me but I am not aware about creating public key using the same.

Can you please give some example on creating public key.

Thanks & Regards,
Ganesh Sankpal

receive output

by wodSupport, Thursday, August 28, 2014, 15:22 (1180 days ago) @ Ganesh Sankpal

Ganesh,

public key without the private key makes no sense, so you cannot just create public key. You wouldn't be able to do with it anything anyway, since all crypto-sensitive information is done with the private key.

Also, public key is just a part of the private key.

So, when you Load or Generate the private key, you can always extract public key out using PublicKeyOpenSSH or PublicKeySSH, depending on the format you need. Of course, of you only extract the public key and don't save the private key - you will not be able to do anything with that key.

Kreso

receive output

by Ganesh Sankpal, Tuesday, September 02, 2014, 14:38 (1175 days ago) @ wodSupport

Hello Kreso,

Thanks for the info. :-)
I am facing one more problem, using wodssh execute method when I execute a command, it takes around 5-7 minutes to get back with the response, I am waiting on the response of that command using Receive method in while loop (if I get a specific keyword, it should come out of the loop). But I am facing time out error.

Please help me on the following questions;
How can I wait for longer time and receive the result given by the command?
Can I use the combination of WaitFor and Receive method? If yes then how to implement it in a proper way?


Thanks & Regards,
Ganesh Sankpal

receive output

by wodSupport, Tuesday, September 02, 2014, 17:01 (1174 days ago) @ Ganesh Sankpal

Ganesh,

I don't know what's going on under the hood, but you can try not to use WaitFor, and rather use Receive method, in a loop.

What you should do is define global variable

Dim InBuffer as String

and then in a loop do something like this

do

InBuffer = InBuffer + Ssh1.Receive
if InStr(InBuffer, 1, "something_I_need_inside") then goto out
loop

or something similar to this. THis way you can control more than one thing in the buffer, and have full buffer that is arriving for your own usage.

Can you try something like that?

Kreso

receive output

by Ganesh Sankpal, Wednesday, September 03, 2014, 08:34 (1174 days ago) @ wodSupport

Hello Kreso,

Thanks for the reply.

Yes, I tried the same thing but problem is, when I am expecting some output using Receive method, it causes time out error as because the command which I run require 5-7 minutes to complete and after the complete execution that command gives the output.
I also defined the time out value for the wodssh object, but it didn't work.

Following is the code snippet,

printf(wodssh->Execute(command, expected_prompt));
string str = wodssh->Receive();

while (str.find("expected_string") != true)
{
Sleep(2000);
str = wodssh->Receive();
}

The above code causes time out error.
Can you please help me on this.

Thanks & Regards,
Ganesh Sankpal

receive output

by wodSupport, Wednesday, September 03, 2014, 09:49 (1174 days ago) @ Ganesh Sankpal

Ganesh,

code is more/less ok, except don't use Sleep to block the thread since wodSSH is living in the same thread.

Rather, set wodSSH->put_Timeout(0) or to some really large value. This will cause wodSSH not to timeout by itself. However, your TCP connection could be broken by 3rd party (such as router, or the server) if there's no traffic for a long period of time.

If wodSSH doesn't timeout by itself, you don't need Sleep so remove it, and just leave Receive call(s) to obtain the data.

Hope this helps!
Kreso

receive output

by Ganesh Sankpal, Wednesday, September 03, 2014, 12:06 (1174 days ago) @ wodSupport

Hi Kreso,

The same thing is happening in my code.
Actually it takes long time for the response to get back. That might be causing remote server connection to abort.
Can you suggest me the way by which I can keep the connection active so that the server will not get disconnected and will keep the connection active until I get the final response which is expected to be received after 5-7 minutes.

Thanks & Regards,
Ganesh Sankpal

receive output

by wodSupport, Wednesday, September 03, 2014, 12:07 (1174 days ago) @ Ganesh Sankpal

Ganesh,

is same thing happening with any other client, such as Putty? If you login manually using Putty and execute the command and wait, does it also timeout?

Kreso

receive output

by Ganesh Sankpal, Wednesday, September 03, 2014, 13:04 (1174 days ago) @ wodSupport

Hi Kreso,

Yes I am getting the time out on putty too.

Regards,
Ganesh Sankpal

receive output

by wodSupport, Wednesday, September 03, 2014, 13:49 (1174 days ago) @ Ganesh Sankpal

Ganesh,

then I'm not sure if you can do anything from the client side.

What kind of OS is on the other side? What command are you executing?

Kreso

receive output

by Ganesh Sankpal, Wednesday, November 12, 2014, 08:37 (1104 days ago) @ wodSupport

Hi,

I am using wodsshcom library and it's APIs. We are having a licensed key of wodssh but I don't find any functionality for putting license key in program.
Can you please help me with this?

Regards,
Ganesh Sankpal

receive output

by Jasmine, Wednesday, November 12, 2014, 10:56 (1104 days ago) @ Ganesh Sankpal

Hi Ganesh.

You have probably downloaded the trial version, which cannot be unlocked with the license key. You should request update from our website:

http://www.weonlydo.com/index.asp?update=1

to obtain latest licensed version, and then install that one.

I hope this helps!
Jasmine.

receive output

by Ganesh Sankpal, Wednesday, November 12, 2014, 14:33 (1104 days ago) @ Jasmine

We have the license version of wodssh. But I don't find the functionality to put license key in my project using wodsshcom dll.
Can you show me the code snippet of using what class and its function I can put license key in the project.

Regards,
Ganesh Sankpal

receive output

by Jasmine, Wednesday, November 12, 2014, 16:33 (1103 days ago) @ Ganesh Sankpal

Hi Ganesh.

You can find explanation here:

http://www.weonlydo.com/SSH/Help/wodSSH-Technical-and-distribution-information.html

you should make sure Version property returns version info without the word 'DEMO' inside. Also, make sure you use wodSSH.DLL, not wodSSH.OCX, since OCX doesn't have the LicenseKey property, and it's initialized by dropping wodSSH on the form.

So, if you use wodSSH.DLL (as COM object), then it's sufficient to do

Ssh1.LicenseKey = "your-license-key"

and that's all! What programming language are you using?

Kind regards.
Jasmine.

receive output

by Ganesh Sankpal, Thursday, November 13, 2014, 06:36 (1103 days ago) @ Jasmine

Hi,

I am using C++, but I didn't find any property ".LicenseKey" as such though I am using wodssh.dll.

Below is the code snippet;

IwodSSHComPtr wodssh;
hres = wodssh.CreateInstance(CLSID_wodSSHCom, NULL);
wodssh->put_Blocking (VARIANT_TRUE);
wodssh->put_Hostname (bstrSite);
wodssh->put_Login (bstrUser);
wodssh->put_Password (bstrPswd);
wodssh->put_Port(22);
wodssh->put_Protocol(SSHAuto);
wodssh->put_Timeout(300);

but I am not getting wodssh->LicenseKey property to set license key.
Can you please help me out.

Regards,
Ganesh Sankpal

receive output

by Jasmine, Thursday, November 13, 2014, 16:19 (1102 days ago) @ Ganesh Sankpal

Hi Ganesh.

Where is your IwodSSHComPtr declared? Did you obtain that file using #import directive, or from our samples?

Kind regards.
Jasmine.