Jump to content
Sign in to follow this  
Phenom

Use AutoIt to monitor a text file

Recommended Posts

Phenom

There is a certain program that is always writing to a log file that is in text format. How can AutoIt be used to constantly monitor what is being written to this text file and take certain actions depending on what new output it sees?

Share this post


Link to post
Share on other sites
4ggr35510n

Infinite loop containing FileRead

Share this post


Link to post
Share on other sites
PsaltyDS

Infinite loop containing FileRead

Well, maybe a loop that checks the time stamp or filesize and reads it only if changed.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Sobiech

i coded this filewatcher ~~ one week ago

; File watcher

$INI = @ScriptDir & "\Settings.ini"
$filename = IniRead($INI, "watching", "filename", ""); Filename
$string = IniRead($INI, "watching", "stringtosearch", ""); String writed to file by bot
$do = IniRead($INI, "watching", "filerun", ""); Run a file after text in file
$exit = IniRead($INI, "watching", "exitiffound", ""); Exit if string was found?

$delay = IniRead($INI, "delays", "searchdelay", ""); Time between loop wil check file again

$File = FileOpen($filename, 0) ; 0 - Read Mode

While 1
If FileReadLine($filename, 1) = $string Then ; If first line of file is our string then...
    ShellExecute($do); Run a file
        If $exit = "true" Then
            Exit
        Else
            ContinueLoop
        EndIf
EndIf
sleep($delay * 1000)
WEnd

FileClose($File)

This should be useful for u

Edited by Sobiech

This world is crazy

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.