Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-27-2019, 11:48 AM
Reno Reno is offline
Registered User
 
Join Date: Mar 2019
Posts: 27
WaitForStrings with the possibility of different prompts returned

In a VBscript, I'm issuing an SSH command. When that SSH is performed, there are two possibilities:
1) the prompt will change to "[admin@xyz123 ~]$ "
2) the VM will ask for the admin passowrd to complete the SSH, where the prompt will look like:
admin@1.1.1.1's password:

I was trying to figure out how to do a "crt.Screen.WaitForString" where the script waits for either prompt and then takes action based on which prompt is returned.

I'm having a little difficulty getting an example working. From looking at the docs, I was thinking it should look something like:
result = crt.screen.WaitForStrings("admin@1.1.1.1's password: ", "[admin@xyz123 ~]$ ", 10)
If result = 1 Then crt.screen.send "testl"
If result = 2 Then crt.screen.send "test2"
If result = 0 Then
MsgBox "Error: Timed out waiting for prompt!"
End If

Thanks for any help!

Last edited by Reno; 03-27-2019 at 11:49 AM. Reason: tyep-o
Reply With Quote
  #2  
Old 03-27-2019, 12:11 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,027
Hi Reno,

Your code looks fine to me (and worked for me in a quick test). I did add a synchronous statement (and used crt.Dialog.MessageBox for all cases rather than send something to the remote):
Code:
crt.Screen.Synchronous = True
crt.Screen.Send "ssh 192.1.1.1" & vbcr
result = crt.screen.WaitForStrings("assword: ", "~]$ ", 10)
If result = 1 Then crt.Dialog.MessageBox "Received password prompt" 
If result = 2 Then crt.Dialog.MessageBox "Already logged in as user" 
If result = 0 Then crt.Dialog.Messagebox "Error: Timed out waiting for prompt!"
What were your results?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 03-27-2019, 02:20 PM
Reno Reno is offline
Registered User
 
Join Date: Mar 2019
Posts: 27
I got it working. I pasted in your code and then changed out the values with mine. That's all I did. Maybe there was something just a little off in the example I pasted.

One things I know, is when I get this things figured out, I'll forever have working examples to copy off myself instead of having to ask questions.

I really appreciate the help. Thank you sir!
Reply With Quote
  #4  
Old 03-27-2019, 02:56 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,027
Hi Reno,

I'm glad you got it working.

Quote:
Thank you sir!
Wrong gender, but that's OK.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 03-27-2019, 04:44 PM
Reno Reno is offline
Registered User
 
Join Date: Mar 2019
Posts: 27
Opps. Pardon. Thank you Ma'am!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 03:27 PM.