View Single Post
  #1  
Old 03-27-2019, 10:48 AM
Reno Reno is offline
Registered User
 
Join Date: Mar 2019
Posts: 35
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 10:49 AM. Reason: tyep-o
Reply With Quote