Sign in to follow this  
Followers 0
catstwespos

Reading Text from a .log file

5 posts in this topic

Hey, i have been working on automating some installs using this software (makes things a TON easier!) but i need more information on if the install works.

i have it set up to save a .log file to inform me if the install is successful or errors, but i am having problems with searching that file for the text. i have tried using wingettext and controlgettext but neither have worked for me.

here is a copy of my code, if anyone could help me with this part that would be great!

$file = FileOpen("install.log", 0)

If $file = -1 Then

MsgBox(0,"Error", "File Not Found")

Exit

ElseIf WinGetText("install - Notepad", "Error:") Then

MsgBox(0, "Error", "Error in Installation!")

ElseIf WinGetText("install - Notepad", "Operation Complete",) Then

MsgBox(0, "Install Complete", "Installation Completed Successfully!")

Else

MsgBox(0, "Error", "Cannot Read File!")

EndIf

FileClose($file)

Share this post


Link to post
Share on other sites



Hi,

maybe have a look at WinWaitActive and so on.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Welcome to the Autoit Forums!!!

maybe..

#include <file.au3>
Dim $aRecords
If Not _FileReadToArray("install.log", $aRecords) Then
    MsgBox(4096, "Error", " Error reading log to Array     error:" & @error)
    Exit
EndIf
For $x = 1 To $aRecords[0]
    If StringInStr($aRecords[$x], "error") Then
        MsgBox(0, "Error", 'Record:' & $x & @CRLF & $aRecords[$x])
        ExitLoop
    ElseIf StringInStr($aRecords[$x], "Complete") Then
        MsgBox(0, "Complete", 'Record:' & $x & @CRLF & $aRecords[$x])
        ExitLoop
    EndIf
Next
 oÝ÷ ÚÚ¢w¥w«jëh×6
If StringInStr(Fileread("install.log"), "error") Then MsgBox(0, "Error", "Error in Installation!")

depends on how many lines and how many "error" or "complete" words are in the file

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

wow! Valuater, your code works AWESOME!

I thought i was going to give up! i even already made a vbscript to do the same job, but yours does it sooo much nicer!

Thanks a TON!

Share this post


Link to post
Share on other sites

Now I got, what you wanted. :">

Sorry, totally missed the point.

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

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  
Followers 0