Joshua Dumas
asked on
Parsing Text File - SCRIPT NEEDED
I have text files that created from Veritas Backup Exec 8.6 and would like some code that can parse through the text file pulling out certain information - such as the following:
Date, Backup Size in GB, which tapes it used to backup, which slot it used to backup, the BEX number (log number), & Job completion status
Can someone helpe me in creating a script that pulls this information outa dn puts it into a text file then I put into an access database......
***********START OF ONE OF THE REPORTS **********************
========================== ========== ========== ========== ========== ====
Job server: SERVER_NAME
Job name: SERVER_NAME Daily
Job started: Monday, April 18, 2005 at 6:02:03 PM
Job type: Backup
Job Log: BEX47.txt
========================== ========== ========== ========== ========== ====
No appendable media could be mounted.
Switching to overwrite operation on scratch media.
Drive and media information from media mount:
Robotic Library Name: COMPAQ 1
Drive Name: COMPAQ 1
Slot: 20
Media GUID: {7E57F902-D34E-442F-9E4B-5 8F3A4E29DE 4}
Media Label: DLT000026
Overwrite Protection Time Left: Infinite
Append Time Left: Infinite
Targeted Media Set Name: Media Set 1
========================== ========== ========== ========== ========== ====
Job Operation - Backup
Media operation - overwrite.
Hardware compression enabled.
========================== ========== ========== ========== ========== ====
Performing Remote Agent backup
Media Name: "Media created 4/18/2005 06:02:04 PM"
Backup of "\\SERVER_NAME\C$ "
Backup set #1 on storage media #1
Backup set description: "SERVER_NAME Daily"
Backup Type: DIFFERENTIAL - Changed Files
Backup started on 4/18/2005 at 6:04:05 PM.
Backup completed on 4/18/2005 at 6:37:52 PM.
Backed up 12809 files in 1602 directories.
21 files were in use
1 item was skipped.
Processed 1,425,049,077 bytes in 33 minutes and 47 seconds.
Throughput rate: 40.2 MB/min
-------------------------- ---------- ---------- ---------- ---------- ----
Performing Remote Agent backup
Media Name: "Media created 4/18/2005 06:02:04 PM"
Backup of "\\SERVER_NAME\D$ "
Backup set #2 on storage media #1
Backup set description: "SERVER_NAME Daily"
Backup Type: DIFFERENTIAL - Changed Files
Backup started on 4/18/2005 at 6:37:53 PM.
Backup completed on 4/18/2005 at 6:39:47 PM.
Backed up 205 files in 9290 directories.
Processed 28,535,042 bytes in 1 minute and 54 seconds.
Throughput rate: 14.3 MB/min
-------------------------- ---------- ---------- ---------- ---------- ----
Performing Remote Agent backup
Media Name: "Media created 4/18/2005 06:02:04 PM"
Backup of "\\SERVER_NAME\E$ "
Backup set #3 on storage media #1
Backup set description: "SERVER_NAME Daily"
Backup Type: DIFFERENTIAL - Changed Files
Backup started on 4/18/2005 at 6:39:47 PM.
Backup completed on 4/18/2005 at 10:10:24 PM.
Backed up 177 files in 12156 directories.
2 files were in use
Processed 7,060,197,361 bytes in 3 hours, 30 minutes, and 37 seconds.
Throughput rate: 32.0 MB/min
-------------------------- ---------- ---------- ---------- ---------- ----
========================== ========== ========== ========== ========== ====
Job Operation - Verify
========================== ========== ========== ========== ========== ====
Verify of "\\SERVER_NAME\C$ "
Backup set #1 on storage media #1
Backup set description: "SERVER_NAME Daily"
Verify started on 4/18/2005 at 10:12:07 PM.
Verify completed on 4/18/2005 at 10:17:09 PM.
Verified 12809 files in 1602 directories.
0 files were different.
Processed 1,425,049,077 bytes in 5 minutes and 2 seconds.
Throughput rate: 270.0 MB/min
-------------------------- ---------- ---------- ---------- ---------- ----
Verify of "\\SERVER_NAME\D$ "
Backup set #2 on storage media #1
Backup set description: "SERVER_NAME Daily"
Verify started on 4/18/2005 at 10:17:09 PM.
Verify completed on 4/18/2005 at 10:17:17 PM.
Verified 205 files in 9290 directories.
0 files were different.
Processed 28,535,042 bytes in 8 seconds.
Throughput rate: 204.1 MB/min
-------------------------- ---------- ---------- ---------- ---------- ----
Verify of "\\SERVER_NAME\E$ "
Backup set #3 on storage media #1
Backup set description: "SERVER_NAME Daily"
Verify started on 4/18/2005 at 10:17:17 PM.
Verify completed on 4/18/2005 at 10:43:10 PM.
Verified 177 files in 12156 directories.
0 files were different.
Processed 7,060,197,361 bytes in 25 minutes and 53 seconds.
Throughput rate: 260.1 MB/min
-------------------------- ---------- ---------- ---------- ---------- ----
========================== ========== ========== ========== ========== ====
Job ended: Monday, April 18, 2005 at 10:44:43 PM
Job completion status: Successful
========================== ========== ========== ========== ========== ====
***********END OF ONE OF THE REPORTS **********************
Any ideas?
Date, Backup Size in GB, which tapes it used to backup, which slot it used to backup, the BEX number (log number), & Job completion status
Can someone helpe me in creating a script that pulls this information outa dn puts it into a text file then I put into an access database......
***********START OF ONE OF THE REPORTS **********************
==========================
Job server: SERVER_NAME
Job name: SERVER_NAME Daily
Job started: Monday, April 18, 2005 at 6:02:03 PM
Job type: Backup
Job Log: BEX47.txt
==========================
No appendable media could be mounted.
Switching to overwrite operation on scratch media.
Drive and media information from media mount:
Robotic Library Name: COMPAQ 1
Drive Name: COMPAQ 1
Slot: 20
Media GUID: {7E57F902-D34E-442F-9E4B-5
Media Label: DLT000026
Overwrite Protection Time Left: Infinite
Append Time Left: Infinite
Targeted Media Set Name: Media Set 1
==========================
Job Operation - Backup
Media operation - overwrite.
Hardware compression enabled.
==========================
Performing Remote Agent backup
Media Name: "Media created 4/18/2005 06:02:04 PM"
Backup of "\\SERVER_NAME\C$ "
Backup set #1 on storage media #1
Backup set description: "SERVER_NAME Daily"
Backup Type: DIFFERENTIAL - Changed Files
Backup started on 4/18/2005 at 6:04:05 PM.
Backup completed on 4/18/2005 at 6:37:52 PM.
Backed up 12809 files in 1602 directories.
21 files were in use
1 item was skipped.
Processed 1,425,049,077 bytes in 33 minutes and 47 seconds.
Throughput rate: 40.2 MB/min
--------------------------
Performing Remote Agent backup
Media Name: "Media created 4/18/2005 06:02:04 PM"
Backup of "\\SERVER_NAME\D$ "
Backup set #2 on storage media #1
Backup set description: "SERVER_NAME Daily"
Backup Type: DIFFERENTIAL - Changed Files
Backup started on 4/18/2005 at 6:37:53 PM.
Backup completed on 4/18/2005 at 6:39:47 PM.
Backed up 205 files in 9290 directories.
Processed 28,535,042 bytes in 1 minute and 54 seconds.
Throughput rate: 14.3 MB/min
--------------------------
Performing Remote Agent backup
Media Name: "Media created 4/18/2005 06:02:04 PM"
Backup of "\\SERVER_NAME\E$ "
Backup set #3 on storage media #1
Backup set description: "SERVER_NAME Daily"
Backup Type: DIFFERENTIAL - Changed Files
Backup started on 4/18/2005 at 6:39:47 PM.
Backup completed on 4/18/2005 at 10:10:24 PM.
Backed up 177 files in 12156 directories.
2 files were in use
Processed 7,060,197,361 bytes in 3 hours, 30 minutes, and 37 seconds.
Throughput rate: 32.0 MB/min
--------------------------
==========================
Job Operation - Verify
==========================
Verify of "\\SERVER_NAME\C$ "
Backup set #1 on storage media #1
Backup set description: "SERVER_NAME Daily"
Verify started on 4/18/2005 at 10:12:07 PM.
Verify completed on 4/18/2005 at 10:17:09 PM.
Verified 12809 files in 1602 directories.
0 files were different.
Processed 1,425,049,077 bytes in 5 minutes and 2 seconds.
Throughput rate: 270.0 MB/min
--------------------------
Verify of "\\SERVER_NAME\D$ "
Backup set #2 on storage media #1
Backup set description: "SERVER_NAME Daily"
Verify started on 4/18/2005 at 10:17:09 PM.
Verify completed on 4/18/2005 at 10:17:17 PM.
Verified 205 files in 9290 directories.
0 files were different.
Processed 28,535,042 bytes in 8 seconds.
Throughput rate: 204.1 MB/min
--------------------------
Verify of "\\SERVER_NAME\E$ "
Backup set #3 on storage media #1
Backup set description: "SERVER_NAME Daily"
Verify started on 4/18/2005 at 10:17:17 PM.
Verify completed on 4/18/2005 at 10:43:10 PM.
Verified 177 files in 12156 directories.
0 files were different.
Processed 7,060,197,361 bytes in 25 minutes and 53 seconds.
Throughput rate: 260.1 MB/min
--------------------------
==========================
Job ended: Monday, April 18, 2005 at 10:44:43 PM
Job completion status: Successful
==========================
***********END OF ONE OF THE REPORTS **********************
Any ideas?
ASKER
and how would I run this....I have created the above calling the file name "backup.vbs", but how do I run it against a certain directory on the backup server?
At the moment it will run on a specific file, the name / location should be specified in:
Set objInputFile = objFileSystem.GetFile("Inp
As you see file selection is currently hard-coded, this is something that can change if required, but the parameters for picking that file need to be worked out.
Still, to make the file locations a little easier (or more obvious) try this version:
Option Explicit
' The location (full path) for the log file you want it to parse
Const INPUTFILE = "c:\program files\veritas\BEX47.txt"
' The location (full path) for the report file you want it to produce
Const OUTPUTFILE = "c:\temp\report.txt"
Dim objFileSystem, objInputFile, objTextStream, objOutputFile
Dim intJobTotal
Dim strLine, strJobStarted, strJobLog, strTotal, strMedia, strSlot, strStatus
Set objFileSystem = CreateObject("Scripting.Fi
Set objInputFile = objFileSystem.GetFile(INPU
Set objTextStream = objInputFile.OpenAsTextStr
Set objOutputFile = objFileSystem.CreateTextFi
intJobTotal = 0
' Read it all in
Do
strLine = objTextStream.ReadLine
If (InStr(strLine, "Job started: ") <> 0) Then
strJobStarted = strLine
strJobStarted = Mid(strJobStarted, 14, Len(strJobStarted))
End If
If (InStr(strLine, "Job Log: ") <> 0) Then
strJobLog = strLine
strJobLog = Mid(strJobLog, 10, Len(strJobLog))
strJobLog = Left(strJobLog, (Len(strJobLog) - 4))
End If
If (InStr(strLine, "Processed ") <> 0) Then
strTotal = strLine
arrTotal = Split(strTotal, " ")
strTotal = Replace(arrTotal(1), ",", "")
intJobTotal = intJobTotal + strTotal
End If
If (InStr(strLine, "Media Name: ") <> 0) Then
strMedia = strLine
strMedia = Mid(strMedia, 14, Len(strMedia))
strMedia = Left(strMedia, (Len(strMedia) - 1))
End If
If (InStr(strLine, "Slot: ") <> 0) Then
strSlot = strLine
strSlot = Mid(strSlot, 7, Len(strSlot))
End If
If (InStr(strLine, "Job completion status: ") <> 0) Then
strStatus = strLine
strStatus = Mid(strStatus, 24, Len(strStatus))
End If
Loop While Not objTextStream.AtEndOfStrea
' Since it counts the verify halve the Job Total then convert it to Gb (2 * 1024 * 1024 * 1024)
intJobTotal = intJobTotal / 2147483648
' Write it out to a file
objOutputFile.WriteLine(st
objOutputFile.WriteLine(st
objOutputFile.WriteLine(in
objOutputFile.WriteLine(st
objOutputFile.WriteLine(st
objOutputFile.WriteLine(st
Set objOutputFile = Nothing
Set objTextStream = Nothing
Set objInputFile = Nothing
Oh, it should be noted that error control in this version is limited to say the least - the idea is more to demonstrate how the file can be parsed than writing a more friendly script.
ASKER
Chris:
Would it be difficult to modify the script to do the script for all files begining with BEX in a certain folder?
Please dont strangle me!
Would it be difficult to modify the script to do the script for all files begining with BEX in a certain folder?
Please dont strangle me!
Don't worry... it's easy...
Before getting too far into it... how do you want the output? The bit below has been changed to Comma Seperated Values rather than something on each line - this meant the date field had to be altered slightly to get rid of the commas in it.
The main part we need to add the script is to get the filenames in the directory. For this we have to attach to the directory, this allows the use of DirectoryObject.Files part of the File System Object. Basically, a directory listing.
Option Explicit
' The location (full path) for the log folder - not a file path
Const LOGFOLDER = "c:\program files\veritas\logs"
' The location (full path) for the report file you want it to produce
Const OUTPUTFILE = "c:\temp\report.txt"
' Variable
Dim objFileSystem, objFolder, objInputFile, objTextStream, objOutputFile
Dim intJobTotal
Dim arrTotal
Dim strLine, strJobStarted, strJobLog, strTotal, strMedia, strSlot, strStatus, strOutput
' Object Initialization
Set objFileSystem = CreateObject("Scripting.Fi
'
' Subroutines
'
Sub ParseLog(objInputFile)
Set objTextStream = objInputFile.OpenAsTextStr
intJobTotal = 0
Do
strLine = objTextStream.ReadLine
If (InStr(strLine, "Job started: ") <> 0) Then
strJobStarted = strLine
strJobStarted = Mid(strJobStarted, 14, Len(strJobStarted))
strJobStarted = Replace(strJobStarted, ",", "")
End If
If (InStr(strLine, "Job Log: ") <> 0) Then
strJobLog = strLine
strJobLog = Mid(strJobLog, 10, Len(strJobLog))
strJobLog = Left(strJobLog, (Len(strJobLog) - 4))
End If
If (InStr(strLine, "Processed ") <> 0) Then
strTotal = strLine
arrTotal = Split(strTotal, " ")
strTotal = Replace(arrTotal(1), ",", "")
intJobTotal = intJobTotal + strTotal
End If
If (InStr(strLine, "Media Name: ") <> 0) Then
strMedia = strLine
strMedia = Mid(strMedia, 14, Len(strMedia))
strMedia = Left(strMedia, (Len(strMedia) - 1))
End If
If (InStr(strLine, "Slot: ") <> 0) Then
strSlot = strLine
strSlot = Mid(strSlot, 7, Len(strSlot))
End If
If (InStr(strLine, "Job completion status: ") <> 0) Then
strStatus = strLine
strStatus = Mid(strStatus, 24, Len(strStatus))
End If
Loop While Not objTextStream.AtEndOfStrea
Set objTextStream = Nothing
' Since it counts the verify halve the Job Total then convert it to Gb (2 * 1024 * 1024 * 1024)
intJobTotal = intJobTotal / 2147483648
End Sub
'
' Main Section
'
Set objOutputFile = objFileSystem.CreateTextFi
Set objFolder = objFileSystem.GetFolder(LO
For Each objInputFile in ObjFolder.Files
If (Left(objInputFile.Name, 3) = "BEX") Then
ParseLog objInputFile
strOutput = strJobLog & "," & strJobStarted & "," & strMedia & "," & strSlot
strOutput = strOutput & "," & intJobTotal & "," & strStatus
objOutputFile.WriteLine(st
End If
Next
Set objFolder = Nothing
Set objOutputFile = Nothing
ASKER
instead of it checking
"Job started: " - can we change that to "Backup started on "
"Media Name: " - can we change that to "Media Label: " BUT ONLY for the backup section NOT the verify section...a backup never falls onto a Verify....heheheh
also lets not do the conversion to GB instead just put what it verified from the Verify Section to Parse "Processed "
Finally, a backup may flow onto two tapes so I need it to parse the entire BEX## file for all slot and Media Label:
Can this be done...??
"Job started: " - can we change that to "Backup started on "
"Media Name: " - can we change that to "Media Label: " BUT ONLY for the backup section NOT the verify section...a backup never falls onto a Verify....heheheh
also lets not do the conversion to GB instead just put what it verified from the Verify Section to Parse "Processed "
Finally, a backup may flow onto two tapes so I need it to parse the entire BEX## file for all slot and Media Label:
Can this be done...??
Sorry for the late reply, must have missed the notification mail.
There are 3 different entries for Backup Started on, do you want them all?
Media Label only appears once, so that bit of code changes to:
If (InStr(strLine, "Media Label: ") <> 0) Then
strMedia = strLine
strMedia = Mid(strMedia, 14, Len(strMedia))
End If
Processed is easy, to leave it as bytes just divide by 2 instead of 2147483648, the total amount processed is still split into 3 parts that have to be added together though.
Reading multiple media labels / slots is no problem, I'll add it in and post an update in a minute or two.
Updated to include all but the Job Started / Backup Start on bits
Option Explicit
' The location (full path) for the log folder - not a file path
Const LOGFOLDER = "c:\program files\veritas\logs"
' The location (full path) for the report file you want it to produce
Const OUTPUTFILE = "c:\temp\report.txt"
' Variable
Dim objFileSystem, objFolder, objInputFile, objTextStream, objOutputFile
Dim intJobTotal, intMedia, intSlots
Dim arrTotal
Dim strLine, strJobStarted, strJobLog, strTotal, strMedia, strSlot, strStatus, strOutput
Dim arrMedia()
Dim arrSlots()
' Object Initialization
Set objFileSystem = CreateObject("Scripting.Fi
'
' Subroutines
'
Sub ParseLog(objInputFile)
Set objTextStream = objInputFile.OpenAsTextStr
intJobTotal = 0
intMedia = -1
intSlots = -1
Do
strLine = objTextStream.ReadLine
If (InStr(strLine, "Job started: ") <> 0) Then
strJobStarted = strLine
strJobStarted = Mid(strJobStarted, 14, Len(strJobStarted))
strJobStarted = Replace(strJobStarted, ",", "")
End If
If (InStr(strLine, "Job Log: ") <> 0) Then
strJobLog = strLine
strJobLog = Mid(strJobLog, 10, Len(strJobLog))
strJobLog = Left(strJobLog, (Len(strJobLog) - 4))
End If
If (InStr(strLine, "Processed ") <> 0) Then
strTotal = strLine
arrTotal = Split(strTotal, " ")
strTotal = Replace(arrTotal(1), ",", "")
intJobTotal = intJobTotal + strTotal
End If
If (InStr(strLine, "Media Label: ") <> 0) Then
strMedia = strLine
strMedia = Mid(strMedia, 14, Len(strMedia))
intMedia = intMedia + 1
ReDim Preserve arrMedia(intMedia)
arrMedia(intMedia) = strMedia
End If
If (InStr(strLine, "Slot: ") <> 0) Then
strSlot = strLine
strSlot = Mid(strSlot, 7, Len(strSlot))
intSlots = intSlots + 1
ReDim Preserve arrSlots(intSlots)
arrSlots(intSlots) = strSlot
End If
If (InStr(strLine, "Job completion status: ") <> 0) Then
strStatus = strLine
strStatus = Mid(strStatus, 24, Len(strStatus))
End If
Loop While Not objTextStream.AtEndOfStrea
Set objTextStream = Nothing
' Since it counts the verify as well as the normal backup halve the Job Total
intJobTotal = intJobTotal / 2
End Sub
'
' Main Section
'
Set objOutputFile = objFileSystem.CreateTextFi
Set objFolder = objFileSystem.GetFolder(LO
For Each objInputFile in ObjFolder.Files
If (Left(objInputFile.Name, 3) = "BEX") Then
ParseLog objInputFile
strOutput = strJobLog & "," & strJobStarted & ","
intMedia = 1
For Each strMedia in arrMedia
strOutput = strOutput & strMedia & "(" & intMedia & "),"
intMedia = intMedia + 1
Next
intSlots = 1
For Each strSlot in arrSlots
strOutput = strOutput & strSlot & "(" & intSlots & "),"
intSlots = intSlots + 1
Next
strOutput = strOutput & intJobTotal & "," & strStatus
objOutputFile.WriteLine(st
End If
Next
Set objFolder = Nothing
Set objOutputFile = Nothing
ASKER
Sorry its been a while...its been pretty hectic around here...I thought the spring/summer months were suppose to be quiet....well is IT ever quiet...HEHEHHE
To answer your questions
There are 3 different entries for Backup Started on, do you want them all?
--No only the first one is fine
I copied the following code and edited where the backup logs are executed the code and I get an error stating:
There is no script file specified..
any ideas?
To answer your questions
There are 3 different entries for Backup Started on, do you want them all?
--No only the first one is fine
I copied the following code and edited where the backup logs are executed the code and I get an error stating:
There is no script file specified..
any ideas?
ASKER
i copied the following code and edited where the backup logs are executed the code and I get an error stating:
There is no script file specified..
my fault.....it appears I typed the extension as a wsh instead of a vbs....stupid me...ITS FRIDAY!!!
There is no script file specified..
my fault.....it appears I typed the extension as a wsh instead of a vbs....stupid me...ITS FRIDAY!!!
ASKER
oops...can you add "Job name: " to the report - it being the first thing on the list when it outputs to the file....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I have no idea about the database writing bit at the end... I really try to avoid those... but this vbscript will parse the file and give you the values. I couldn't figure out which field you wanted for the tape, so I took Media Name.
Option Explicit
Dim objFileSystem, objInputFile, objTextStream, objOutputFile
Dim intJobTotal
Dim strLine, strJobStarted, strJobLog, strTotal, strMedia, strSlot, strStatus
Set objFileSystem = CreateObject("Scripting.Fi
Set objInputFile = objFileSystem.GetFile("Inp
Set objTextStream = objInputFile.OpenAsTextStr
Set objOutputFile = objFileSystem.CreateTextFi
intJobTotal = 0
' Read it all in
Do
strLine = objTextStream.ReadLine
If (InStr(strLine, "Job started: ") <> 0) Then
strJobStarted = strLine
strJobStarted = Mid(strJobStarted, 14, Len(strJobStarted))
End If
If (InStr(strLine, "Job Log: ") <> 0) Then
strJobLog = strLine
strJobLog = Mid(strJobLog, 10, Len(strJobLog))
strJobLog = Left(strJobLog, (Len(strJobLog) - 4))
End If
If (InStr(strLine, "Processed ") <> 0) Then
strTotal = strLine
arrTotal = Split(strTotal, " ")
strTotal = Replace(arrTotal(1), ",", "")
intJobTotal = intJobTotal + strTotal
End If
If (InStr(strLine, "Media Name: ") <> 0) Then
strMedia = strLine
strMedia = Mid(strMedia, 14, Len(strMedia))
strMedia = Left(strMedia, (Len(strMedia) - 1))
End If
If (InStr(strLine, "Slot: ") <> 0) Then
strSlot = strLine
strSlot = Mid(strSlot, 7, Len(strSlot))
End If
If (InStr(strLine, "Job completion status: ") <> 0) Then
strStatus = strLine
strStatus = Mid(strStatus, 24, Len(strStatus))
End If
Loop While Not objTextStream.AtEndOfStrea
' Since it counts the verify halve the Job Total then convert it to Gb (2 * 1024 * 1024 * 1024)
intJobTotal = intJobTotal / 2147483648
' Write it out to a file
objOutputFile.WriteLine(st
objOutputFile.WriteLine(st
objOutputFile.WriteLine(in
objOutputFile.WriteLine(st
objOutputFile.WriteLine(st
objOutputFile.WriteLine(st
Set objOutputFile = Nothing
Set objTextStream = Nothing
Set objInputFile = Nothing