Automating a script - WeOnlyDo Discussion board

Automating a script (wodSSH / wodSSH.NET)

by Shawn, Tuesday, October 23, 2007, 03:30 (6242 days ago)

This issue is found using VB6. I have recently purchased the ssh control and I am struggling to get it to do exactly what I want. Using your example as a base, I have created this logon on code:

Ssh.HostName = ip
Ssh.Login = user
Ssh.Password = pw
Ssh.Protocol = SSH2
Ssh.Prompt = Password:
Ssh.Blocking = True
AddToList Connecting... & vbCrLf
Ssh.Connect

Running just this code and I am prompted to enter the password. By adding this command

ssh.Send PW , 0

and I am connected to the device. I setup a button that will send the following command

Ssh.send host info -sf -n 20 -i & vbLf

If I push one button to connect and then the second button to send the command everything works as expected and the results are displayed in the results textbox.

The problem is that I want this to execute entirely in one go. When I run the code

Ssh.HostName = ip
Ssh.Login = user
Ssh.Password = pw
Ssh.Protocol = SSH2
Ssh.Prompt = Password:
Ssh.Blocking = True
AddToList Connecting... & vbCrLf
Ssh.Connect
Send PW , 0
Ssh.send host info -sf -n 20 -i & vbLf

The results do not appear to be written to the received buffer. I have tried putting a time delay between the send functions (uses a timer control) but is does not help.

Thank you,
Shawn

Re: Automating a script

by woddrazen, Tuesday, October 23, 2007, 07:43 (6242 days ago) @ Shawn

Hi Shawn,


What happened if you just put:
--------------------------------
Ssh.WaitFor ( regex:[\$ #>] $ )
--------------------------------

before Send Method line in your code.

Maybe this will quickly fix your problem.

Let us know how it goes.


Regards,
Drazen

Re: Automating a script

by Shawn, Tuesday, October 23, 2007, 18:29 (6242 days ago) @ woddrazen

Hi Shawn,


What happened if you just put:
--------------------------------
Ssh.WaitFor ( regex:[\$ #>] $ )
--------------------------------

before Send Method line in your code.

Maybe this will quickly fix your problem.

Let us know how it goes.


Regards,
Drazen

I tried to suggestion but it did not resolve the issue. I did find a workaround by creating a timer and having it fire off the rest of my code after a 5 second delay. This seems to give the control enough time to flush the buffer. Now I will see how short of a delay I need can get away with.

Thank you for your help.

Shawn

Re: Automating a script

by wodDamir, Tuesday, October 23, 2007, 18:48 (6241 days ago) @ Shawn

Hi Shawn,

Did you try using the Execute method?

Perhaps that would help, as it will execute a command and wait for a certain string to be received, before continuing with the code.

Regards,
Damba