Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read the last 5 lines of text file

Status
Not open for further replies.

lhailey

Programmer
Sep 24, 2010
4
US
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 = fso_OpenTextFile( 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top