Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-17-2013, 01:57 PM
anunda anunda is offline
Registered User
 
Join Date: Jan 2013
Posts: 1
Add timeout on script

I have been using the scripting function to automatic different functions with Cisco devices usually 200-500 devices. All the routers authenticate through a tacacs server. The problem I have is that I will run into a router that will not authenticate or has been taken off line and the whole script will freeze up. How can I put a timeout value so it will skip a router/host that does not respond?

example of script:

' Verbiles to use in scripts
Dim Username
Username="NAME "
Dim Password
Password="Password"
DIm Enablepassword
EnablePassword="ENPASSWORD"
DIm Command
Command="term len 0"
DIm Command2
Command2="sh run "
Dim host(200)
host (0) = "10.0.0.1"
host (1) = "10.0.0.2"
host (2) = "10.0.0.3"
host (3) = "10.0.0.4"
host (4) = "10.0.0.5"
host (5) = "10.0.0.6"

For Each strHost In host
If strHost = "" Then Exit For
' Make sure we are disconnected before attempting a connection
If crt.Session.Connected Then crt.Session.Disconnect



' connect to host on port 23 (the default telnet port)
'
crt.Screen.Synchronous = True
crt.Session.Connect "/TELNET " & strHost


''''''''''''''' Login Part ''''''''''''''''''''''

crt.Screen.WaitForString "sername:"

crt.Screen.Send Username & vbCr

crt.Screen.WaitForString "assword:"

crt.Screen.Send Password & vbCr

crt.Screen.WaitForString ">"

crt.Screen.Send "en" & vbCr

crt.Screen.WaitForString "assword:"

crt.Screen.Send Enablepassword & vbCr


' worked to log last host. how to append

crt.session.LogFileName = "c:\temp\"&strHost&".txt"

crt.session.Log(true)



crt.Screen.WaitForString "#"

crt.Screen.Send Command & vbCr

crt.Screen.WaitForString "#"

crt.Screen.Send Command2 & vbCr

crt.Screen.WaitForString "#"

Next
Reply With Quote
  #2  
Old 08-19-2013, 08:55 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,305
Hi anunda,

Thanks for the question. One way to accomplish your goal would be to handle the connection and authentication in a tab. You can find an example of how this can be done at the following location:
http://forums.vandyke.com/showthread...7087#post37087
Does this help you accomplish your goal?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
Reply

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:14 PM.