Can you help modify this script?
I have a working script (below) that will read the last line of a text file and then report whether the specific text ("Charlie Brown") was found or not.
I would like to modify the script to read the last 5 lines of the text file and then report if ("Charlie Brown") was found or not.
---------------------------------------------
filedir = "C:\Users\nelson\Desktop\Slot1.log"
Do Until TextFound1
ForReading = 1
Set fso = CreateObject( "Scripting.FileSystemObject" )
Set textFile = fspenTextFile( filedir, ForReading )
Do Until textFile.AtEndOfStream
lineNextStr = textFile.ReadLine
If Len( lineNextStr ) > 0 Then
lineStr1 = lineNextStr
End If
Loop
textFile.Close
If lineStr1 = "Charlie Brown" Then
TextFound1 = True
print "Slot1 " & lineStr1 & " was found!"
Reporter.ReportEvent 0, "Slot 1", DataTable("Visible", dtLocalSheet) & " text was found!"
Else
print "Slot1 " & lineStr1 & " was not found!"
wait 5
End If
Loop
'end loop
I have a working script (below) that will read the last line of a text file and then report whether the specific text ("Charlie Brown") was found or not.
I would like to modify the script to read the last 5 lines of the text file and then report if ("Charlie Brown") was found or not.
---------------------------------------------
filedir = "C:\Users\nelson\Desktop\Slot1.log"
Do Until TextFound1
ForReading = 1
Set fso = CreateObject( "Scripting.FileSystemObject" )
Set textFile = fspenTextFile( filedir, ForReading )
Do Until textFile.AtEndOfStream
lineNextStr = textFile.ReadLine
If Len( lineNextStr ) > 0 Then
lineStr1 = lineNextStr
End If
Loop
textFile.Close
If lineStr1 = "Charlie Brown" Then
TextFound1 = True
print "Slot1 " & lineStr1 & " was found!"
Reporter.ReportEvent 0, "Slot 1", DataTable("Visible", dtLocalSheet) & " text was found!"
Else
print "Slot1 " & lineStr1 & " was not found!"
wait 5
End If
Loop
'end loop