12 posts in this topic
I have another AutoIT script making a Log file
Sample of Log file:
2016/08/22 12:44:18 > Process: [RUNNING] [ACTIVE] 2016/08/22 12:48:35 > Process: [WAS NOT RUNNING] 2016/08/22 13:40:00 > Process: [FAILED] 2016/08/22 14:01:10 > Process: [WAS NOT RUNNING] I am looping through the Log file for the word "FAILED"
I then want to get all lines that have "FAILED" and get their TIME
My Current code to get this far:
If FileExists($fileLog) Then $contents = FileRead($fileLog) If @error Then MsgBox(0, 'File Error', $fileLog & ' could not be read.') Else For $i = 1 To _FileCountLines($fileLog) $result = StringInStr($contents,$search) If $result >= 1 Then $filteredLine = FileReadLine($fileLog,$i) If StringInStr($filteredLine,$search) Then ConsoleWrite($filteredLine & @CRLF) ; this gets me the results I want sans the time parse EndIf Else ConsoleWrite( $search & " not found!" & @CRLF) EndIf Next EndIf EndIf For this part:
If StringInStr($filteredLine,$search) Then ConsoleWrite($filteredLine & @CRLF) ; this gets me the results I want sans the time parse EndIf OUTPUT: 2016/08/22 13:40:00 > Process: [FAILED] I dont understand how I read the time in that output?
I have tried _DateTimeFormat - Dont think this applies
Tried _DateDiff - I dont have a the date yet so this doesnt work
Would love if someone could tell me if I am thinking is the wrong direction and possibly lead me down the correct path to light side of the force
Hi there - quite a beginner to codding so please bare with me...
i am writing an autoit code that will be running 24/7 executing various tasks every 10-20 minutes. it suppose to run on unattended server but i would like to occasionally remote log in and do stuff on the server without disturbing the autoit script (while the autoit script is in Sleep count). to achieve this I will need to know at what point in the commands run it is and how long roughly until the next command (I use Sleep in between commands)...
so, is there a way to create a monitor that shows me the last command executed and how long of the Sleep is left (like in a small window or in the windows task bar)?
failing that any idea how can I utilize the FileWriteLog function to keep updating an always open text file ?
thanks in advance
Are there any people here that know how to use a parser generator that uses 'bnf' (not 'ebnf'!)
i'm using the gold parser:
not possible in autoit:
What i'm looking for is the best way to parse a list:
<List> ::= <Item> ',' <List> | <Item> <Item> ::= Number | String for example, the tree returned from:
'test', 1, 2 is:
since its not possible in AutoIT code I did it in vb script.
this is what i did:
' in the parse loop: Case Rule_List_Comma set result = new list call result.input(.tokens(0).data,.tokens(2).data) ' the list class: class list private arg0 private arg1 public sub input(a,b) set arg0 = a set arg1 = b end sub private sub push(item,byref stack) redim preserve stack(ubound(stack) + 1) stack(ubound(stack)) = item end sub public function value value = array(arg0.value) value2 = arg1.value if isarray(value2) then for each thing in value2 push thing,value next else push value2,value end if end function end class
is there a better way to do this?
I have been a member for a while but relatively new to posting to the message boards. I am also still relatively new to using AutoIt. I am working on a script that will help keep a program running on one of my file servers.
Here is what I have accomplished so far looking at different threads on the site already.
1. A check performed every 60 seconds to see if the application is running. (ultimately to be changed to something like once an hour)
2. Write a log file that shows either the check was performed with no issue or the application had to be restarted.
Both of those are working fine and I have to say that ever since I started using this script the program has not crashed!
My next phase is to figure out how to make the script check and trim the log file. I am obviously not trying to make a log file that becomes bloated and chews up a large amount of hard drive space. The main purpose of the log file is so that I know if the application has been restarted. I am thinking have the script trim the file every 30 day maybe. Another words delete everything in the log file 30 days prior to the current day. So if someone can help me out here as I am not a scripting genius. Unfortunately I only know enough to be dangerous if you will.
I also have another part of this script I want to write but first I want to get the log file working just the way I want. I am attaching a sample of what I have working so far.
Thank you for any and all help folks.
#include <File.au3> While 1 ;Start Loop If ProcessExists("atcsmon.exe") Then ;~ Open the logfile in write mode. Local $hFile = FileOpen(@ScriptDir & "\ATCS_AutoIt.log", 1) _FileWriteLog($hFile, "ATCS check was completed and found running by the AutoIt3 Script") ; Write to the logfile passing the filehandle returned by FileOpen. FileClose($hFile) ; Close the filehandle to release the file. Else ;If Process does not exist Run("C:\atcs_monitor\atcsmon.exe", "", @SW_SHOWMINIMIZED) ;~ Open the logfile in write mode. Local $hFile = FileOpen(@ScriptDir & "\ATCS_AutoIt.log", 1) _FileWriteLog($hFile, "*ALERT* *ALERT* *ALERT* ATCS was restarted by the AutoIt3 Script") ; Write to the logfile passing the filehandle returned by FileOpen. FileClose($hFile) ; Close the filehandle to release the file. EndIf Sleep(60000) ;sleep 60 seconds WEnd ;Close Loop
i have an interesting question about the gold parser:
download (regsvr32 to register):
on the website it seems that this dll can be used as an activex object,
does that mean that it can be used in autoit to?
help for the activeX dll:
it gives me error code '4' if i try to use it...
Const $gpMsgAccept = 3 Const $gpMsgCommentBlockRead = 9 Const $gpMsgCommentError = 7 Const $gpMsgCommentLineRead = 10 Const $gpMsgInternalError = 8 Const $gpMsgLexicalError = 5 Const $gpMsgNotLoadedError = 4 Const $gpMsgReduction = 2 Const $gpMsgSyntaxError = 6 Const $gpMsgTokenRead = 1 $Parser = ObjCreate("goldparserengine.goldparser") $Parser.LoadCompiledGrammar("test_script.cgt") $Parser.OpenFile("Program.txt") $Response = $Parser.Parse() MsgBox(0,'test',$Response) If there are people interested in answering or helping feel free to reply and then i will upload the "test_script.cgt" somewhere if you want
i know this question is a bit specific but you never know..
Thanks for reading!