Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting

Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 07-24-2018, 12:27 PM
BjoernH BjoernH is offline
Registered User
Join Date: Mar 2018
Posts: 41
Vbscript: unable to break out of waitfors loop

Good day.

I've been trying to write this vbscript that is supposed to log into 10 different servers based on the IP array, and extract some information from each. The script compiles, but it remains in a loop on the first server, always looping back to line #34 (crt.Screen.WaitForStrings).

'#$language = "VBScript"
'#$interface = "1.0"

crt.Screen.Synchronous = True

Sub Main()

Dim vHosts(10)
vHosts (0) = ""
vHosts (1) = ""
vHosts (2) = ""
vHosts (3) = ""
vHosts (4) = ""
vHosts (5) = ""
vHosts (6) = ""
vHosts (7) = ""
vHosts (8) = ""
vHosts (9) = ""

AuthE = InputBox("Please enter the euser password:","","*")
	If AuthE = ""  Then Exit Sub
For Each strHosts In vHosts
    If strHosts = "" Then Exit For
    crt.Screen.Send"ssh euser@" & strHosts & vbCr

Dim vWaitFors
vWaitFors = Array("(yes/no)?", _

	Dim nResult
	nResult = crt.Screen.WaitForStrings(vWaitFors, 5)

	Select Case nResult

		Case 1
			crt.Screen.Send"yes" & vbCr
		Case 2
			crt.Screen.Send AuthE & vbCr
		Case Else
	crt.Screen.Send"echo;hostname;ip a|grep int-oam;echo" & vbCr

	end Select

	crt.Screen.Send"exit" & vbCr

End Sub

Any help or pointers appreciated.

Thanks in advance,
Reply With Quote

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 10:19 PM.