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 04-11-2018, 08:45 AM
respite respite is offline
Registered User
Join Date: May 2017
Posts: 6
Script only running on a few hosts at a time

Hello again,

I've been tasked with polling all of our branch Cisco switches for their iOS version and deploy a patch to them after.

My problem is, for whatever reason, my script seems to only want to run on two "vHosts" at once before just sitting there and not obeying the "crt.Session.disconnect" command. When the script stops, I have to manually disconnect the session, then the script will proceed. Any ideas? Script is below.

*Note: there will be many more hosts than just the ones listed, about 900 more*

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

crt.Screen.Synchronous = True

on error resume next

Dim vHosts(1000)

vHosts(0) = ""
vHosts(1) = ""
vHosts(2) = ""
vHosts(3) = ""
vHosts(4) = ""
vHosts(5) = ""
vHosts(6) = ""

For Each strHost In vHosts
 If strHost = "" Then Exit For

 ' Make sure we are disconnected before attempting a connection
 If crt.Session.Connected Then crt.Session.Disconnect
  Dim logfile
  logfile = "C:\Users\nmorra\Documents\Scripts\logs\switch-version.log"
  crt.Session.LogFileName = logfile
  crt.Session.Log True, True

 ' Connect to the next host
 crt.Session.Connect "/SSH2 /L * /PASSWORD * " & strHost

	crt.Screen.WaitForString "#"
	crt.Screen.Send "sh version | inc Cisco IOS Software" & chr(13)
	crt.Screen.WaitForString "#"
	crt.Screen.Send "quit" & chr(13)
Reply With Quote

hang , multiple-hosts , poll

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 08:00 AM.