This should be pretty easy to script using the scripting language of
your choice.  If you know VBScript, you can use a combination of
SendKeys and regular expression searches to find the appropriate
information and export/save to a CSV file.  I've written something
similar for one of our helpdesk staff that gathers Earthlink access
numbers using IE.  Code is below.  This could be modified easily to do
what you need.
I would caution you (unless I'm mistaken but I doubt it) against running
the "sh ip nat trans" on a router that doesn't have more than the
minimum recommended RAM for your IOS version.  I've crashed a router
more than once while running this command after it built up a sizeable
translation table.

VBScript below
'''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
'On Error Resume Next

': Declare and set global variables
Dim objFSO, objCmdShell, vReturn
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objCmdShell = CreateObject("Wscript.Shell")
'Const ForReading = 1, ForWriting = 2, ForAppending = 8

Dim RegEx, strPattern, strRepl, strMatch, strMatches
Set RegEx = New RegExp
RegEx.Global = True
RegEx.IgnoreCase = True

Call GetNumbers()
':=============================================================

Sub GetNumbers()

                Dim arrStates(51)
                arrStates(0) = "AL"
                arrStates(1) = "AK"
                arrStates(2) = "AZ"
                arrStates(3) = "AR"
                arrStates(4) = "CA"
                arrStates(5) = "CO"
                arrStates(6) = "CT"
                arrStates(7) = "DE"
                arrStates(8) = "DC"
                arrStates(9) = "FL"
                arrStates(10) = "GA"            
                arrStates(11) = "HI"
                arrStates(12) = "ID"
                arrStates(13) = "IL"
                arrStates(14) = "IN"
                arrStates(15) = "IA"
                arrStates(16) = "KS"
                arrStates(17) = "KY"
                arrStates(18) = "LA"
                arrStates(19) = "ME"
                arrStates(20) = "MD"
                arrStates(21) = "MA"
                arrStates(22) = "MI"
                arrStates(23) = "MN"
                arrStates(24) = "MS"
                arrStates(25) = "MO"
                arrStates(26) = "MT"
                arrStates(27) = "NE"
                arrStates(28) = "NV"
                arrStates(29) = "NH"
                arrStates(30) = "NJ"
                arrStates(31) = "NM"
                arrStates(32) = "NY"
                arrStates(33) = "NC"            
                arrStates(34) = "ND"
                arrStates(35) = "OH"
                arrStates(36) = "OK"
                arrStates(37) = "OR"
                arrStates(38) = "PA"
                arrStates(39) = "RI"
                arrStates(40) = "SC"
                arrStates(41) = "SD"
                arrStates(42) = "TN"
                arrStates(43) = "TX"
                arrStates(44) = "UT"
                arrStates(45) = "VT"
                arrStates(46) = "VA"
                arrStates(47) = "WA"
                arrStates(48) = "WV"
                arrStates(49) = "WI"
                arrStates(50) = "WY"
                
        Dim strFileName
        strFileName =
"D:\Scripts\EarthlinkAccessNumbers\EarthlinkAccessNumbers.txt"
                
        Dim strAllEarthLinkNumbers
        strAllEarthLinkNumbers =
"D:\Scripts\EarthlinkAccessNumbers\AllEarthLinkNumbers-" & Year(Now) &
Month(Now) & Day(Now) & ".csv"
                
        Dim i
        For i = 0 To UBound(arrStates) - 1
                Dim strState, strURL
                strState = arrStates(i)
                strURL =
"http://support.earthlink.net/support/ACCESS/search_print.jsp?"; & _
        
"type=us&linkid=1001362&area=&prefix=&number=&state=" & strState & _ 
                        "&accs_type=Modem&printable=1"                  
                        
                objCmdShell.Run "iexplore"
                objCmdShell.AppActivate "Microsoft Internet Explorer"
                WScript.Sleep 2000
                        
                objCmdShell.SendKeys "{TAB}"
                WScript.Sleep 500
                objCmdShell.SendKeys "+" & strURL
                WScript.Sleep 500
                objCmdShell.SendKeys "{ENTER}"
                Wscript.Sleep 15000
                        
                ': Send CTRL+A
                objCmdShell.SendKeys "^a"
                Wscript.Sleep 2000
                objCmdShell.SendKeys "^c"
                Wscript.Sleep 2000
                objCmdShell.SendKeys "%(fc)"
                Wscript.Sleep 2000
                        
                If objFSO.FileExists(strFileName) Then
                        objFSO.DeleteFile(strFileName)
                End If                  
                        
                objCmdShell.Run "notepad"
                objCmdShell.AppActivate "notepad"
                WScript.Sleep 2000
                objCmdShell.SendKeys "^v"
                Wscript.Sleep 2000
                objCmdShell.SendKeys "%(fs)"
                Wscript.Sleep 2000
                objCmdShell.SendKeys "+" & strFileName
                Wscript.Sleep 2000
                objCmdShell.SendKeys "{ENTER}"
                Wscript.Sleep 2000
                objCmdShell.SendKeys "%(fx)"
                        
                Dim objAllNumbersFile
                Set objAllNumbersFile =
objFSO.OpenTextFile(strAllEarthLinkNumbers, 8, True)            
                        
                Dim objFile, strLine, numTest, strTelNumber,
strCityState, numTelLength
                Dim strLineLen, strCSVFileLine
                Set objFile = objFSO.OpenTextFile(strFileName, 1)
                Do While NOT objFile.AtEndOfStream
                        strLine = Trim(objFile.ReadLine)
                        strLineLen = Len(strLine)
                        strPattern = "(\d+)"
                        RegEx.Pattern = strPattern
                        numTest = RegEx.Test(strLine)
                        If numTest Then
                                strPattern = "(^\d+\s+\d+\s+\d+)"
                                RegEx.Pattern = strPattern
                                Set strMatches = RegEx.Execute(strLine)
                                For Each strMatch in strMatches
                                        strTelNumber = Trim(strMatch)
                                
                                        strPattern = "(\s)"
                                        RegEx.Pattern = strPattern
                                        strRepl = "-"
                                        strTelNumber =
RegEx.Replace(strTelNumber, strRepl)
                                        numTelLength =
Len(Trim(strTelNumber))
                                        strCityState =
Trim(Right(strLine, (strLineLen - numTelLength)))
                                                
                                        strCSVFileLine = strTelNumber &
"," & strCityState
                                        Wscript.Echo "Writing line " &
strCSVFileLine
        
objAllNumbersFile.WriteLine(strCSVFileLine)

                                Next
                        Else
                                Wscript.Echo "THIS IS NOT AN ACCESS
NUMBER LINE"
                        End If
                Loop
                objFile.Close
                objAllNumbersFile.Close
                Next
End Sub
':======================================================================
===

Set objFSO = Nothing
Set objCmdShell = Nothing

Wscript.Echo vbCrLf & "End of Script" & vbCrLf

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Vijay Ramcharan


-----Original Message-----
From: Gabriele [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, January 22, 2003 5:33 AM
To: [EMAIL PROTECTED]
Subject: NAT translation table [7:61553]


hi!

Does anyone knows if it's possible to export the cached NAT translation
table (the one you get with "sh ip nat trans") somehow? The export
should occur in a specified time range (e.g every 10 seconds). I need
the information for a software project about accounting of ip traffic.
the software itself cannot access the router by a console session ....
the cisco in use is a 3640 with IOS 12.1T.

thx a lot in advance
gabriele




Message Posted at:
http://www.groupstudy.com/form/read.php?f=7&i=61579&t=61553
--------------------------------------------------
FAQ, list archives, and subscription info: http://www.groupstudy.com/list/cisco.html
Report misconduct and Nondisclosure violations to [EMAIL PROTECTED]

Reply via email to