Thread: traceroute
View Single Post
Old 05-24-2012, 06:00 AM
rainman rainman is offline
Registered User
Join Date: Apr 2012
Posts: 16

Hello, I want to complete a traceroute from a server to a set of IP addresses contained in a text file, and save each trace output to an individual file named by the IP address. Unfortunately it is not working the way I expect it to. The attached script will read the IP addresses and complete a traceroute and output all IP addresses trace result to the screen and at the same time the script creates one .txt file in the directory C:\temp and will add the first trace result to the text file only. No other text files are created. Can someone please advise what I am doing wrong here please ? Thanks.

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

' Turn on synchronous mode while performing Send/Wait sequences
' so no input is missed.
crt.Screen.Synchronous = True

Sub Main

'read file with IP and set path
Const DEVICE_FILE_PATH = "c:\temp\devices.txt"

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim fil
Set fil = fso.OpenTextFile(DEVICE_FILE_PATH)

Dim ip

Dim cnxnString

Dim logfile
logfile = ("C:\temp\" & ip & ".txt")
crt.Session.LogFileName = logfile
crt.Session.Log True

While Not fil.AtEndOfStream
ip = fil.ReadLine
cnxnString = "/usr/sbin/traceroute " & ip & vbCr

crt.Screen.Send cnxnString
crt.Screen.WaitForString "servername$"
crt.Screen.Send vbCr

' Stop logging
crt.Session.Log False

' Turn off synchronous mode
crt.Screen.Synchronous = false

crt.Screen.WaitForString "servername$"

crt.Screen.Synchronous = False
End Sub
Reply With Quote