'******************************************************************
'*
'* ParseStartgrpLog.vbs by Si
'*
'*
'*
'******************************************************************
'Option Explicit
'On Error Resume Next
Dim strOutputLog
Dim appLog
Dim SearchString
Dim objTextFile
Dim strNextLine
Dim intSize
Dim objSendMail
Dim objFSO
Dim i
Dim ErrorString
Dim newArray
appLog = ".\savegrp.log"
grpStart = "NetWorker savegroup:"
intSize = 0
strOutputLog = ""
Const ForReading = 1
' If Instr() returns 0 then "cscript.exe" is not the host,
' alert the user and return
If Instr(1, WScript.FullName, "cscript.exe", vbTextCompare) = 0 then
MsgBox " Host: " & WScript.FullName & vbCRLF & _
"This script must be executed by cscript.exe", _
vbCritical, _
"Error: " & Wscript.ScriptFullName
Wscript.Quit(1) ' return error code to caller
End If
' Send a email message with the extracted log file info
Sub SendMail(Sender, Recipient, Subject, Message)
Set objSendMail = CreateObject("CDO.Message")
objSendMail.From = Sender
objSendMail.To = Recipient
objSendMail.Subject = Subject
objSendMail.TextBody = Message
objSendMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
objSendMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = _
"192.168.70.18"
objSendMail.Configuration.Fields.Item _
("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
objSendMail.Configuration.Fields.Update
objSendMail.Send
set objSendMail = Nothing
End Sub
'Get the current DD/MM/YY as strings.
strDay = Right("00" & Cstr(Day(Date())-1),2)
strDay1 = Right("00" & Cstr(Day(Date())),2)
strMonth = Right("00" & Cstr(Month(Date())),2)
strYear = Cstr(Year(Date()))
strDateFrom = strDay & "-" & strMonth & "-" & strYear
strDateTo = strDay1 & "-" & strMonth & "-" & strYear
strOutputLog = strOutputLog & "Running Report for 06:00 " & strDateFrom & " to 06:00 " & strDateTo & vbcrlf
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
(appLog, ForReading)
Do Until objTextFile.AtEndofStream
strNextLine = objTextFile.ReadLine
If InStr (strNextLine, grpStart) Then
If InStr (strNextLine, "(alert)") Then
gpN = Split (strNextLine, ":") 'isolate the group save set
grpName = Split (gpN(4), ",")
strOutputLog = strOutputLog & vbcrlf & grpName(0) & vbcrlf
strOutputLog = strOutputLog & "******************************************" &_
"****************************" & vbcrlf & vbcrlf
strNextLine = objTextFile.ReadLine
Do Until InStr (strNextLine, grpStart)
strOutputLog = strOutputLog & strNextLine & vbcrlf
strNextLine = objTextFile.ReadLine
Loop
strOutputLog = strOutputLog & (vbcrlf & "************************************" &_
"**********************************" & vbcrlf)
Else
gpN = Split (strNextLine, ":") 'isolate the group save set
grpName = Split (gpN(4), ",")
strOutputLog = strOutputLog & grpName(0) & vbcrlf
strNextLine = objTextFile.ReadLine
stTime = Split (strNextLine, ":")
startTime = vbtab & stTime(3) & stTime(4) & ":" & stTime(5) & ":" & stTime(6)
strOutputLog = strOutputLog & startTime & vbcrlf
strNextLine = objTextFile.ReadLine
spTime = Split (strNextLine, ":")
stopTime = vbtab & spTime(3) & spTime(4) & ":" & spTime(5) & ":" & spTime(6)
strOutputLog = strOutputLog & stopTime & vbcrlf
End If
End If
Loop
objTextFile.Close
strOutputLog = strOutputLog & "All Done"
SendMail "networker@mybackup.com", "si@myaddress.com", "Networker SaveGroup Log", strOutputLog
WScript.Echo(strOutputLog)