View Single Post
  #4  
Old 12-23-2004, 10:36 AM
wasodg2 wasodg2 is offline
Registered User
 
Join Date: Dec 2004
Location: Spokane, WAshington
Posts: 16
Thumbs up

This is one way to get log information off of Switches. This script I wrote to just get the infomation off of multiple switches, you can change the command to get the information you want off of routers as well. you must change the line where the enable password and the log in password goes, or it won't log you in.

The script will ask the user to supply a folder where the log files are created tehn it will start reading IP address off of the SwitchIP.txt file located at C:\SwitchIP.txt.

Like I said though, I'm not sure if the same commands work on the routers you are trying to get at, but this should give you an idea on how to get what you want.

If you know the exact commands, I can try write something for you.








# $language = "VBScript"
# $interface = "1.0"
'=================================================================
'LANG :VBScript
'NAME ave Gest
'VERSION : 1
'Date ec 23, 2004
'Description :Gets Logging information off of Cisco 2950 and 2900 Switches
' Using the SecureCRT Program scripting Function and VBScript.
' The script reads IP address from a file called C:\SwitchIP.txt
' And Connects to each switch via the SecureCRT and places
' the Log information into a text files named after teh IP address
' of each Switch IE:192.168.0.2.Log
' The Log file are located in afolder which the user inputs at the
' Start of the script.
' For Switches it cannot connect to it logs the IP address into another
' Text file called NoConnect.txt located into the same folder.
'==================================================================
'VARIABLES
Dim FSO, Shell, Windir, Runservice, oFile, oFile1
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set FSO = CreateObject("scripting.filesystemobject")
Set Shell = CreateObject("WScript.Shell")
Set SwitchIP = FSO.opentextfile("C:\SwitchIP.txt", ForReading, False)
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objSc = crt.Screen
Set objD = crt.Dialog
Set objSe = crt.Session
Set objW = crt.Window
Logfiles = objD.Prompt("Enter folder name and Path to save Log files In.","Folder Name & Path","C:\LogFiles")

If FSO.FolderExists(Logfiles) Then
Else
FSO.CreateFolder(Logfiles)
End IF

While Not SwitchIP.atEndOfStream
IP = SwitchIP.Readline()

' connect To host On port 23 (the Default telnet port)
On Error Resume Next
objse.Connect "/TELNET "&IP&" 23"

If ( objse.connected ) Then
objsc.Synchronous = True
objse.logfilename = Logfiles&"\"&IP&".Log"
objse.Log(True)
objSc.WaitForString "assword:"
objSc.Send "LOGIN PASSWORD GOES HERE!!!!" & vbCr
objsc.WaitForString">"
objSc.Send "ena" & vbCr
objSc.WaitForString "assword:"
objSc.Send "ENABLE PASSWORD GOES HERE!!!!!" & vbCr
objSc.WaitForString "#"
objSc.Send "sho logging" & vbCr
objSc.WaitForString"-",2
objSc.Send " "&vbCr
objSc.WaitForString"#",2
objse.Log(False)
objSc.Synchronous = False
objSE.Disconnect

Else

Set Tempfile = FSO.OpenTextFile(Logfiles&"\NoConnect.txt",ForAppending, True)
TempFile.writeline "Could Not Connect to " & IP
TempFile.Close()
End If
Wend
Reply With Quote