Testing WodSSH prompt - WeOnlyDo Discussion board

Testing WodSSH prompt (General questions)

by Tamir, Monday, October 26, 2009, 19:04 (5506 days ago)

Hello,

I'm using WodSSH for a while, and it's quite complicated to my customers to define the 'prompt' property. I'd like to offer them to test it on realtime, while the application is running and connected to a UNIXLinux server.

What such a test do you suggest? I'd like to offer them to enter free text of prompt or regex, and then returns an answer if it's suitable to the server prompt. I have to take a decision what test to do in the server side. Do you have such a well-known test?

Thanks in advance

Re: Testing WodSSH prompt

by woddrazen, Monday, October 26, 2009, 20:00 (5505 days ago) @ Tamir

Hi Tamil,


Why don't you try to use regular expressions inside Prompt Property?

You can try with:

\$ #>

means it will accept any of those chars (\,$, ,#,>) if they appear at the end of the line. This includes 99.9 of most UNIX command prompts (including root account).

More help for Prompt Property you can find here:
http://www.weonlydo.com/SSH/Help/WODSSHLib~wodSSH~Prompt.html

If I maybe didn't understand your question, can you maybe explain it little bit more so we can try to help you?

Let us know how it goes.


Regards,
Drazen

Re: Testing WodSSH prompt

by Tamir, Monday, October 26, 2009, 21:01 (5505 days ago) @ woddrazen

Thanks. I'll clarify myself.

The default prompt in my app is your suggested regex regex:[$ #>] $ and it covers most of situations. But my question is about the other situations when it's not covered. I'm looking for a simple way to suggest my users to customize the prompt by themselves, offering them to change the prompt and immediately test it (in run-time). For instance, changing the prompt to regex:blah-blah $ and then test it on the remote server. I'm wondering what test I should do on the remote server to make sure that the prompt is well-defined.

Thanks.

Hi Tamil,


Why don't you try to use regular expressions inside Prompt Property?

You can try with:

\$ #>

means it will accept any of those chars (\,$, ,#,>) if they appear at the end of the line. This includes 99.9 of most UNIX command prompts (including root account).

More help for Prompt Property you can find here:
http://www.weonlydo.com/SSH/Help/WODSSHLib~wodSSH~Prompt.html

If I maybe didn't understand your question, can you maybe explain it little bit more so we can try to help you?

Let us know how it goes.


Regards,
Drazen

Re: Testing WodSSH prompt

by woddrazen, Monday, October 26, 2009, 21:55 (5505 days ago) @ Tamir

Tamir,


You can determine if prompt is correct using PromptReceived Event. When prompt from Prompt Property is received PromptReceived Event should be fired.

Can you please try that and let us know how it goes?

More help for PromptReceived Event you can find here:
http://www.weonlydo.com/SSH/Help/WODSSHLib~wodSSH~PromptReceived_EV.html


Drazen

Re: Testing WodSSH prompt

by Tamir, Tuesday, October 27, 2009, 18:22 (5505 days ago) @ woddrazen

Thanks!

I think that I use it quite different. Here's my procedure. Can you tell me if I can integrate it with your suggestion, and if so - how exactly?
Thanks

[code]
If ssh1.State = WODSSHCOMLib.StatesEnum.Connected Then
ssh1.Disconnect() 'True
End If

ssh1.Protocol = WODSSHCOMLib.ProtocolsEnum.SSHAuto
ssh1.Blocking = True

ssh1.Connect()

ssh1.WaitFor(my_prompt)

ret = (ssh1.Execute(strExec & vbLf, my_prompt, my_timeout))

[/code]

Tamir,


You can determine if prompt is correct using PromptReceived Event. When prompt from Prompt Property is received PromptReceived Event should be fired.

Can you please try that and let us know how it goes?

More help for PromptReceived Event you can find here:
http://www.weonlydo.com/SSH/Help/WODSSHLib~wodSSH~PromptReceived_EV.html


Drazen

Re: Testing WodSSH prompt

by wodDamir, Tuesday, October 27, 2009, 18:30 (5505 days ago) @ Tamir

Tamir,

If I understood you correctly, you're actually trying to test if user provided the correct prompt for their server.

In that case, you can use your code. However, I would suggest small changes. I.e: you can remove the Execute call.

This should be sufficient:

[php]ssh1.Connect
Dim ret as String
ret = ssh1.WaitFor(your_prompt, 10) [/php]

What above code does, is return everything received by the component before the specified prompt arrives. If it doesn't arrive, a Timeout exception will be thrown on WaitFor call, which means that the Prompt isn't correct.

Hope this helps.

Regards,
Damba