Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-28-2013, 09:20 AM
keejo keejo is offline
Registered User
 
Join Date: May 2013
Posts: 1
help with timeout in a loop when telneting

hi, i use script to backup config files automatically, but there is a problem occured when i running my scripts.

my code is like this
Code:
#$language = "VBScript"
#$interface = "1.0"

Sub Main
On Error Resume Next
' Open the hosts file
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set fileHosts = fso.OpenTextFile("d:\ip.txt", 1)
szHost = fileHosts.ReadLine
Do While len(szHost) > 4
crt.session.connect("/telnet " & szHost)
crt.Screen.Synchronous = True
crt.Screen.Send VbCr
' Commands
crt.Screen.WaitForString "Password:"
crt.Screen.Send "password1234" & chr(13)
crt.Screen.WaitForString "router> "

' START WRITING FILE
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const ForAppending = 8
' Create a new file (or overwrite an existing one)
Set objStream = objFSO.OpenTextFile( _
"D:\MyDataFile.txt", _
ForAppending, _
True)
objStream.WriteLine crt.Session.RemoteAddress
' END WRITING FILE
' Commands
crt.Screen.Send "exit" & chr(13)
szHost = fileHosts.ReadLine
Loop
End Sub
my problem is that when there is an ip in the ip.txt file is cannot be connected, the crt will not timeout, so the script cannot ignore this ip and go to the next. how can i modify the code to let te script ignore the ips that cannot be connected and move on? thank you very much!
Reply With Quote
  #2  
Old 05-28-2013, 04:45 PM
jjh jjh is offline
VanDyke Customer Support
 
Join Date: Feb 2004
Posts: 811
Hello keejo.

The solution to the problem you are experiencing with your
script is described in chapter 3.6 or our scripting manual,
which you can find on the following web page:
http://www.vandyke.com/support/tips/...ing/index.html
Does this help you to get past the connections that don't
work?

Thank you

JJH
Reply With Quote
Reply


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 12:49 PM.