Quote:
Originally posted by rnealejr
You can use the following:
Dim fso As New FileSystemObject
Dim ts As TextStream
Dim strTemp as String
'Open file.
Set ts = fso.OpenTextFile(filename)
'Loop while not at the end of the file.
Do While Not ts.AtEndOfStream
strTemp = ts.ReadLine
Loop
'use strTemp as needed
'Close the file.
ts.Close
|
Okay, so I'm obviously lost here...that being said, I have what you have given me and understand it to a degree, but I am uncertain how to incorporate that into what I already have (or would it be simpler to just create a new script altogether?) Anyway, here's what I have, can you give me some direction? I mean, you don't have to rewrite the thing for me (obviously) but if you could give me some pointers on where stuff needs to go within what I already have, I think that'd help out a whole bunch...here goes....!
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("d:\filedir\monitor.log")
Do While objTextFile.AtEndOfStream <> True
arrAMSMonitor = split(objTextFile.Readline, ";")
LogDate = Mid(arrAMSMonitor(3),13,19)
If arrAMSMonitor(0) = "MSPAvailability=down" And DateDiff("n", Now, LogDate) > -5 Then
Wscript.Echo "A down event was detected at " & Time & ". " & vbCr & "The log file recorded this event at " & LogDate & "." & vbCr & "Please check \\SERVERNAME\servershare\monitor.log for more information."
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "user@domain.com"
objEmail.To = "user@domain.com"
objEmail.Subject = "SERVER Monitor Error Reported"
objEmail.Textbody = "A down event was detected at " & LogDate & ". Please check \\SERVERNAME\servershare\monitor.log for more information." & vbCrLf & "NOTE: As this error may have been previously reported; please note the date/time of last occurrence."
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.state.ky.us"
objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
End If
i = i + 1
Loop
objTextFile.Close
You see, right now, it's looking for a keyword in the first part of the array that it's taking from this text file and reporting if it finds that info. In addition to this, what I'd like for it to do is look at the very last line of this text file, check the time and date against the current time and date and report if that time and date checked isn't within the last 10 minutes (I know I'm being repetitive, but I'd rather do that than have you help me get something I don't need).
By the way, thanks for your time and help...I sincerely appreciate it.