Hi,
I have a log file I must look through each morning to see if there were any failures the previous day. Here's a small sample
I found a script online that seems close, but I haven't been able to get it to work. Can someone help? Here's the script
I have a log file I must look through each morning to see if there were any failures the previous day. Here's a small sample
Code:
1/16/2013 1:40:00 PM | Starting process ==========================================================
1/16/2013 1:40:00 PM | Import ERP order email data...
1/16/2013 1:40:01 PM | Imported Record Count = 0
1/16/2013 1:40:01 PM | Task Time: 0.4992 seconds
1/16/2013 1:40:01 PM | Import ERP order email data...
1/16/2013 1:40:01 PM | Imported Record Count = 0
1/16/2013 1:40:01 PM | Task Time: 0.078 seconds
1/16/2013 1:40:01 PM | Pre-validate email addresses ...
1/16/2013 1:40:01 PM | Invalid Email Count = 0
1/16/2013 1:40:01 PM | Task Time: 0.3432 seconds
1/16/2013 1:40:01 PM | Check order's ship date freshness...
1/16/2013 1:40:01 PM | Unfresh Record Count = 0
1/16/2013 1:40:01 PM | Task Time: 0.0468 seconds
1/16/2013 1:40:01 PM | Re-checking delivery records that have a Soft-Bounce status..
1/16/2013 1:40:04 PM | !!Unknown delivery results returned; ELSE in RecheckBouncedDeliveryResults() called.
1/16/2013 1:40:04 PM | Delivery: Del ID=aa5rc6c1-ss7f-23ef-a458-dac848876rd1 | Del Status=sent | Del Type=transactional
1/16/2013 1:40:04 PM | !!Unknown delivery results returned; ELSE in RecheckBouncedDeliveryResults() called.
1/16/2013 1:40:04 PM | Delivery: Del ID=9idj925-10pp-4def-a3dd-cca4a8479200 | Del Status=sent | Del Type=transactional
1/16/2013 1:40:04 PM | Re-checked delivery count: 4
1/16/2013 1:40:04 PM | Task Time: 2.7768 seconds
1/16/2013 1:40:04 PM | Get delivery results from Server...
5/25/2013 1:40:39 PM | New contacts count: 0
5/25/2013 1:40:39 PM | Task Time: 33.9612 seconds
5/25/2013 1:40:39 PM | Sending emails via Server system ...
5/25/2013 1:40:40 PM | An error occurred while receiving the HTTP response to [URL unfurl="true"]https://api.Server.com[/URL] This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
5/25/2013 1:40:40 PM | Email count sent for Server delivery: 0
5/25/2013 1:40:40 PM | Task Time: 0.546 seconds
5/25/2013 1:40:40 PM | Total Elapsed Time: 39.624 seconds
5/26/2013 1:40:40 PM | Process finished.
5/26/2013 1:40:39 PM | New contacts count: 0
5/26/2013 1:40:39 PM | Task Time: 33.9612 seconds
5/26/2013 1:40:39 PM | Sending emails via Server system ...
5/26/2013 1:40:40 PM | An error occurred while receiving the HTTP response to [URL unfurl="true"]https://api.Server.com[/URL] This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
5/26/2013 1:40:40 PM | Email count sent for Server delivery: 0
5/26/2013 1:40:40 PM | Task Time: 0.546 seconds
5/26/2013 1:40:40 PM | Total Elapsed Time: 39.624 seconds
5/26/2013 1:40:40 PM | Process finished.
I found a script online that seems close, but I haven't been able to get it to work. Can someone help? Here's the script
Code:
computer = CreateObject("WScript.Network").ComputerName
today = vbsFormat(Now, "M/d/yyyy h:mm:ss tt")
'MsgBox(today)
Set fso = CreateObject("Scripting.FileSystemObject")
Set input = fso.OpenTextFile("c:\action.txt", 1)
Set output = fso.OpenTextFile("c:\error.txt", 2)
Do Until input.AtEndOfStream
line = input.ReadLine
'If Left(line, Len(today)+1) = "[" & today Then
If Left(line, Len(today)) = today Then
' line timestamped with today's date
If InStr(line, "error") > 0 Then
' line contains "error"
output.WriteLine line & vbTab & input.ReadLine & vbTab & computer
End If
End If
Loop
input.Close
output.Close
Public Function vbsFormat(Expression, Format)
vbsFormat = CoreFormat("{0:" & Format & "}", Expression)
End Function
' Allows more of the .NET formatting functionality to be used directly if required
Public Function CoreFormat(Format, Expression)
CoreFormat = Expression
On Error Resume Next
With CreateObject("System.Text.StringBuilder")
.AppendFormat Format, Expression
If Err=0 Then CoreFormat = .toString
End With
End Function