DeFactos Posted March 9, 2011 Share Posted March 9, 2011 Hey, I have a log file that I need to read continually and get the last line from it (to be precise a part of the line so if anyone has any ideas it would be great. Thanks in advance. Link to comment Share on other sites More sharing options...
fett8802 Posted March 9, 2011 Share Posted March 9, 2011 This would work: While 1 $File = FileOpen("Path to File") ;Open the file $Line = FileReadLine($File,-1) ;-1 reads the last line of the file ;Your Line variable now has the contents of the current last line of the file FileClose($File) ;Close the file to allow writing by other programs Sleep(250) ;Sleep 250 milliseconds to allow fresh write to the log file WEnd You'll want to set a hotkey to stop/pause the program What are you wanting to do with the line once you have it? -Fett [sub]My UDF[/sub][sub] - Basics and Time extensions. Great for those new at AutoIt, also contains some powerful time extensions for pros.[/sub][sub]ScrabbleIt[/sub][sub] - Scrabble done in pure AutoIt. (In Progress)[/sub][sub]Nerd Party Extreme | My Portfolio | [email="fett8802@gmail.com"]Contact Me[/email][/sub] Link to comment Share on other sites More sharing options...
DeFactos Posted March 9, 2011 Author Share Posted March 9, 2011 (edited) I want to analyse it ( to find a partial match so if the line is 'Hey everyone you rock.' I want to check if it contains 'everyone'. ) And thanks I think that would work but don't have time to check it right now. Edit1: O.o I forgot to wright a curucial part of my request it doesn't have an extension . Sorry for this but I thought I have written it. Edit2: It opens with notpad. Edited March 9, 2011 by DeFactos Link to comment Share on other sites More sharing options...
DeFactos Posted March 10, 2011 Author Share Posted March 10, 2011 Sorry for bumping but does anyone else have ideas??? Link to comment Share on other sites More sharing options...
Carlo84 Posted March 10, 2011 Share Posted March 10, 2011 _stringbetween() StringInStr() check helpfile _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
DeFactos Posted March 10, 2011 Author Share Posted March 10, 2011 Thanks this should work great. Link to comment Share on other sites More sharing options...
Carlo84 Posted March 10, 2011 Share Posted March 10, 2011 (edited) i whas bored, press esc to abort script HotKeySet('{ESC}', '_exit') While 1 $File = FileOpen("Path to File") ;Open the file $Line = FileReadLine($File, -1) ;-1 reads the last line of the file FileClose($File) ;Close the file to allow writing by other programs If StringInStr($Line, 'everyone') <> 0 Then ExitLoop ; if string contains everyone then exitloop and make coffee Sleep(250) ;Sleep 250 milliseconds to allow fresh write to the log file WEnd MsgBox(64, 'String found', 'now lets make coffee') Func _exit() Exit EndFunc ;==>_exit Edited March 10, 2011 by Djarlo _SplashProgressImage | _Regionselector | _IsPressed360 | _UserAccountContol_SetLevel | _ListSubFolders Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now