Jump to content

Created log/append to log


Recommended Posts

Hi all,

I've been writing a small sync log that I use to sync to my NAS server to benchmark what kind of time it takes to transfer the backups. Now the creating of the file works but the appending doesn't work. and I have absolutely no idea how to get it to work. Any ideas on appending section?

EDIT: Ignore this. I have fixed it....

CODE

#include <Word.au3>

run("Test.exe")

sleep(5000)

if ProcessExists("Test.exe") Then

$logfile = _WordCreate ("C:\Documents and Settings\Administrator\Desktop\ServerSyncLog.doc",0,0)

$append = _WordDocGetCollection ($logfile, 0)

$append.Range.insertAfter ("Date Started: " & @HOUR & ":" & @MIN & ":" & @SEC & " / " & @MON & "/" & @MDAY & "/" & @YEAR & @CRLF)

_WordQuit ($logfile, -1)

EndIf

while processexists("Test.exe")

sleep(2000) ;Check / How many minutes? 2 sec for test

WEnd

_WordDocOpen ($logfile,"C:\Documents and Settings\Administrator\Desktop\ServerSyncLog.doc","\ServerSyncLog.doc")

$append.Range.insertAfter ("Date Ended: " & @HOUR & ":" & @MIN & ":" & @SEC & " / " & @MON & "/" & @MDAY & "/" & @YEAR & @CRLF)

_WordQuit ($logfile, -1)

Edited by herr5407
Link to comment
Share on other sites

Does the log output have to be a Word Document (first encounter for me :D ) ?

If not switch to a pure AutoIt code (w/o using word.au3) and check the help file for FileWriteLine (and related file function).

The other good alternative is _FileWriteLog UDF (file.au3).

Link to comment
Share on other sites

Well, theoretically it doesn't have to be a Word document. I just had a log file writer script written beforehand so I figured I would use the code I already have.

My syntax was completely wrong in the code block that I originally posted. I've gotten it to work properly.

Basically I'm using a program to sync data to a NAS server. I'm too lazy to setup Rsync right now. I was to make sure my backup jobs finish before it starts to replicate so this script will come in handy (that isn't shown in the code though).

AutoIT (once again), saves the day.

The other good alternative is _FileWriteLog UDF (file.au3).

I'll check this out as well. Thx!

Edited by herr5407
Link to comment
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
 Share

  • Recently Browsing   0 members

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