Welcome to the VanDyke Software Forums

Join the discussion today!

Go Back   VanDyke Software Forums > Scripting

Thread Tools Rate Thread Display Modes
Old 12-22-2004, 06:23 AM
bojankus bojankus is offline
Registered User
Join Date: Dec 2004
Posts: 4
Saving in directory

Hello everybody,

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
Reply With Quote
Old 12-22-2004, 04:33 PM
wasodg2 wasodg2 is offline
Registered User
Join Date: Dec 2004
Location: Spokane, WAshington
Posts: 16
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?
Reply With Quote
Old 12-23-2004, 01:14 AM
bojankus bojankus is offline
Registered User
Join Date: Dec 2004
Posts: 4
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
Reply With Quote
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
'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:
' 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
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"
objSc.WaitForString "assword:"
objSc.Send "LOGIN PASSWORD GOES HERE!!!!" & vbCr
objSc.Send "ena" & vbCr
objSc.WaitForString "assword:"
objSc.Send "ENABLE PASSWORD GOES HERE!!!!!" & vbCr
objSc.WaitForString "#"
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
End If
Reply With Quote
Old 12-23-2004, 12:11 PM
adeshotel adeshotel is offline
Registered User
Join Date: Dec 2004
Location: Houston, TX
Posts: 14
SYSLOG server


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

And under PIX it is:

logging on
logging trap warnings
logging facility 23
logging host inside

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.

Reply With Quote
Old 12-23-2004, 05:07 PM
wasodg2 wasodg2 is offline
Registered User
Join Date: Dec 2004
Location: Spokane, WAshington
Posts: 16
That sounds liket the best idea!
Reply With Quote

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 04:24 PM.