Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nortel Passport 15K Data Parser

Status
Not open for further replies.

areotree

Technical User
Feb 16, 2003
24
US
'############################################################################
'# PPKParser
'#
'# ! NO TECHNICAL SUPPORT IMPLIED !
'#
'# This stand alone VBS script will parse and ";" delimit a file with the output from
'# a Nortel Passport 7K/15K/20K that has been dumped by raw table format into separate
'# files. The files can then be easily imported into Excel or some other application.
'#
'# The files must be in a capture directory called "C:\CRT_logs\PPK_Logs\".
'#
'# The input file would look something like:
'#
'# ====================================================================
'# 1375> d -o vr/* pp/*
'#
'# Vr/* Pp/*
'# Use -noTabular to see hidden attributes: atmAddress.
'# +================+====================+------+-----+----+-----+-----
'# | Vr | Pp |snmpOp|osiAd|osiO|osiUs|ifInd
'# | | |erStat| min |per | age | ex
'# | | | us | | | |
'# +================+====================+------+-----+----+-----+-----
'# |0 |OAMENET0 |up |unlck|ena |activ| 3
'# |3 |H248AN |up |unlck|ena |activ| 15
'# |3 |H248VRAP |up |unlck|ena |activ| 16
'#
'# ====================================================================
'#
'# And the output file should look like this:
'#
'# ====================================================================
'# 0;OAMENET0;up;unlck;ena;activ;3
'# 3;H248AN;up;unlck;ena;activ;15
'# 3;H248VRAP;up;unlck;ena;activ;16
'# ====================================================================
'#
'# Requirements:
'#
'# For the script to work you must have the GooyScript.exe file in the
'# the "C:\CRT_Logs" directory on your PC.
'#
'############################################################################
Dim filesys, Wshshell
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Set Wshshell = WScript.CreateObject("WScript.Shell")
Set filesys = WScript.CreateObject("Scripting.FileSystemObject")
'-------------------------------------------------------------------------------------
'---- Register GooeyScript.exe if found, if not quit the script
'-------------------------------------------------------------------------------------
If filesys.fileExists("C:\CRT_logs\GooeyScript.exe") then
Wshshell.Run "C:\CRT_logs\GooeyScript.exe /regserver",1,True
Else
msgbox "This script requires the GooeyScript Component in the 'C:\CRT_logs\' directory."
WScript.Quit
End if
'-------------------------------------------------------------------------------------
'---- Sets up a connection to the GooeyScript component; Create an object called Form1.
'-------------------------------------------------------------------------------------
Set Form1 = WScript.CreateObject("GooeyScript.Form")
'-------------------------------------------------------------------------------------
'---- Sets up a regExp pattern for the parse search
'-------------------------------------------------------------------------------------
Dim regExp1 : Set regExp1 = New RegExp
regExp1.Global = False
regExp1.Pattern = "^\|[0-9]+\|.*$"
regExp1.IgnoreCase = True
Dim regExp2 : Set regExp2 = New RegExp
regExp2.Global = False
regExp2.Pattern = "^[0-9]+;.*$"
regExp2.IgnoreCase = True
'-------------------------------------------------------------------------------------
'---- Check to see if the capture directory exist.
'-------------------------------------------------------------------------------------
If filesys.FolderExists("C:\CRT_logs\PPK_Logs\") = False Then
msgbox "The 'C:\CRT_logs\PPK_Logs\' directory does not exist."
WScript.Quit
End If
'-------------------------------------------------------------------------------------
'---- Load form on the screen.
'-------------------------------------------------------------------------------------
Form1.Load , , 400, 100, "Passport 7/15K/20K File Parser", True
Form1.BackColor 0,0,0
Form1.ForeColor 200,200,200
Form1.ontop = True
Form1.label.load "Info",18,10,,,"Processing file:"
Form1.label.font "Info",true,8
Form1.label.forecolor "info",255,255,255
Form1.ProgressBar.Load 10,40,375,20,""
Form1.ProgressBar.BackColor 0,0,0
Form1.ProgressBar.LabelColor 255,255,255
Form1.ProgressBar.Font false,8
'-------------------------------------------------------------------------------------
'---- Parse the file in the capture directory.
'-------------------------------------------------------------------------------------
Set objFolder = filesys.GetFolder("C:\CRT_logs\PPK_Logs\")
For Each objfile in objFolder.Files
Form1_KeepAlivePing ' just in case the scripts dies clean up the form
Form1.ProgressBar.Value ,objfile
Set testFile = filesys.OpenTextFile(objFile.path, ForReading)
Report="" 'the idea to be proper requires reset to empty'
Do Until testFile.AtEndOfStream
varLine = testFile.ReadLine
Do While Instr(varLine, " ")
varLine = Replace(varLine, " ", "")
Loop
If (regExp1.Test(varLine)) Or (regExp2.Test(varLine)) Then
If (Left(varLine,1) = "|") Then
Report = Report & Mid(Trim(varLine),2) & vbCrLf
Else
Report = Report & Trim(varLine) & vbCrLf'
End If
End If
Loop
'Change delimiter
Report = Replace(Report, "|", ";")
''''''''''Write the changed text back to the file
Set testFile = filesys.OpenTextFile(objFile.path, ForWriting)
testFile.Write Report
testFile.Close
For K = 1 To 1000000
'put this in so you can see the file names in the Processbar
Next
Next
'-------------------------------------------------------------------------------------
'---- Unload form.
'-------------------------------------------------------------------------------------
Form1.Unload
Set Form1 = Nothing
'-------------------------------------------------------------------------------------
'---- This is the KeepAlive Event procedure that gets called every few seconds from
'---- GooeyScript. This procedure responds back to GooeyScript to tell it that the
'---- script is still running. If the script for some reason stop running, then
'---- GooeyScript will do it's best to unload the form, and will at a minimum Hide
'---- the form, since it is useless without the script. Use of this Sub Procedure is
'---- Optional.
'-------------------------------------------------------------------------------------
MsgBox (" ***** Parsing of the PPK files complete !!! *****")
Sub Form1_KeepAlivePing()
Form1.keepAlivePong
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top