Saving in directory
im trying to write a script which gets data(logfile) of every router in that WAN...
i have a problem in making it supposing to do the following:
It shoud ask you for folder where do you want to save
than for each statistics it shoud write a file whos name is the name of currently active cisco router in that folder (static path)
i dont know if securecrt supports ....
anyway i appologize for syntax errors in english
Nice day, bojankus
So you want to automatically log into the router and get the name, then Log that information into folders which is supplied by an input box that the user fills in, right?
Do you want each router to go into seporate folders or all in one?
yes all router logs go in one folder
i guess i must use folder dialog, in wich i select the folder and so on...
but if i want to save previus directory i must make some text file or something in order to read and write folder path in it...is that correct?
thanks and nice day,Bojan
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"
'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.
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
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"
objSc.Send "LOGIN PASSWORD GOES HERE!!!!" & vbCr
objSc.Send "ena" & vbCr
objSc.Send "ENABLE PASSWORD GOES HERE!!!!!" & vbCr
objSc.Send "sho logging" & vbCr
objSc.Send " "&vbCr
objSc.Synchronous = False
Set Tempfile = FSO.OpenTextFile(Logfiles&"\NoConnect.txt",ForAppending, True)
TempFile.writeline "Could Not Connect to " & IP
If all you're after are to get the log files have you tried setting up a syslog server? Many free ones out there and you just set up as a service on a server. The IOS commands are short and sweet:
logging trap notifications
Then all the logs go to the syslog server and you don't have to worry about missing any because the log file on the device wrapped on you. Using CatOS it is:
set logging server enable
set logging server 10.10.10.10
And under PIX it is:
logging trap warnings
logging facility 23
logging host inside 10.10.10.10
Using a syslog server you also don't have to worry about a script failing to run to collect your logs. If you pass through any firewalls you'll have to open up port 514 UDP though.
|Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)|
|Display Modes||Rate This Thread|