View Single Post
Old 02-20-2021, 07:40 AM
HappyHouse HappyHouse is offline
Registered User
Join Date: Feb 2021
Posts: 2
Error detecting in loop

Hello VanDyke team,

Im a rookie in scripting an need help.
Ive a small VBA Script using a loop to connect to several routers to request several coomands. This works fine. But sometimes a router is not reachable. in this case the loop stops with an error. What I need is that my script detects the problem (router not reachable) and go on with the next router in list.

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

crt.Screen.Synchronous = True

Sub Main

Dim objFileToRead, fileLocation, strLine, counter1

fileLocation = crt.Dialog.FileOpenDialog("Choose file")

Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile(fileLocation,1)

do while not objFileToRead.AtEndOfStream

strLine = objFileToRead.ReadLine()

	crt.Screen.Send "login " & strline & chr(13)
	crt.Screen.WaitForString "Password for xxxxxx: " 
	crt.Screen.Send "xxxxxxxx" & chr(13)
	crt.Screen.WaitForString strline 
	crt.Screen.Send "sh ver " & chr(124) & " i uptime" & chr(124) & "System image" & chr(13)
	crt.Screen.WaitForString strline
	crt.Screen.Send "exit" & chr(13)
    crt.Screen.WaitForString "INFO:    Session closed", "2"



Set objFileToRead = Nothing
crt.Dialog.MessageBox("Done !!")

End Sub
Reply With Quote