Reading Last Line of Log

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
fightcancer
Macro Veteran
Posts: 260
Joined: Fri Apr 15, 2005 8:32 am

Reading Last Line of Log

Post by fightcancer » Mon Oct 01, 2007 6:15 pm

What's the easiest way to read the last line of a text log file please?

Is there some combo of ReadFile, Separate and ReadLn I can use? Thanks.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Oct 01, 2007 6:45 pm

ReadFile>c:\bla\logfile.log,FullFile
Separate>FullFile,CRLF,Lines
Let>last=Lines_%Lines_Count%
MessageModal>last
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

fightcancer
Macro Veteran
Posts: 260
Joined: Fri Apr 15, 2005 8:32 am

Post by fightcancer » Mon Oct 01, 2007 6:46 pm

Awesome! Thanks M!

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Mon Oct 01, 2007 7:09 pm

Does this help?
From one of my earlier postings in July 2006
The old DOS "FIND" command may work for you.

Try this from a command line:
FIND "qqq" c:\path\file.txt /v /c

You will get two lines back with a count of all the lines that do not contain "qqq" on the second line.

If that works for you then you can run that with Run Program command:

Run Program>command.com /c FIND "qqq" C:\path\file.txt /v /c > c:\path\lines.txt
ReadLn>c:\path\lines.txt,2,result
MessageModal>Line count = %result%
//You can use other lines to strip out everything to the left of the colon in %result%
==================
Edited: Hmm too slow today. There was no reply when I started this. Marcus' solution is much better.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts