Jump to content

Recommended Posts

Posted

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.

Posted

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]
Posted (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 by DeFactos
Posted (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 by Djarlo

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...