 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
strictlyfocused02
Joined: 21 Jan 2009 Posts: 45
|
Posted: Wed Mar 11, 2009 10:50 am Post subject: Help me optimize this v.100+ RegExMatch's |
|
|
Im reading (Loop, Read) a PuTTY log file for certain keywords. It is possible that I will need to match hundreds of key terms and I cant imagine the way Ive done it is the most efficient way (a new RegExMatch for every key term). It works perfectly in its current state, Im just looking for a way to improve performance and readability by not having 100+ different lines for RegExMatch.
Heres a typical haystack (i.e. CurrentOPCOM in my RegExMatch exmaples)
| Code: | %%%%%%%%%%% OPCOM 11-MAR-2009 07:53:08.75 %%%%%%%%%%% (from node AX12 at 11-MAR-2009 07:53:08.73)
Request 3246320, from user SYSTEM on AX12
"*** FTP transfer GEOMICRO_LIGHTNING could not log in ***" |
And heres a VERY trimmed down example of how Im searching for my key terms | Code: | ;Watch the log file for OPCOMS that match this criteria
Loop {
CurrentOPCOM := Tail(7,AX26log)
If (RegExMatch(CurrentOPCOM,"i)FTP transfer.*could not log in"))
GoSub, AnswerOPCOM
else if (RegExMatch(CurrentOPCOM,"i)FTP transfer.*had a 5xx error during transfer"))
GoSub, AnswerOPCOM
else if (RegExMatch(CurrentOPCOM,"i)Error during.*FTP Transfer"))
GoSub, AnswerOPCOM
else if (RegExMatch(CurrentOPCOM,"i)Job.*on queue.*has duplicates running"))
GoSub, AnswerOPCOM
} |
As a side note, I recently had an idea on how to make this better than what I had originally written it. My first draft looked like this and as you can well imagine it was much slower than it needed to be since it would read the file EVERY single time it checked for a key term. | Code: | | If (RegExMatch(Tail(7,AX26log),"i)FTP transfer.*could not log in")) |
I got thinking about it and realized it would probably work better by assigning the Tail function to a variable that way it was only reading the logfile 1 time per loop which seemed to speed things up greatly. |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1046
|
Posted: Wed Mar 11, 2009 9:35 pm Post subject: |
|
|
Can you give some example "haystacks"? Also, why not use InStr instead (or can't you)?
Also, what are you using the RegEx for? Is it that you have a list of items and you need to see if the specific item matches one of them? If so, a continuation block combined with a parse loop would be cleaner code.
| Code: | items =
(
Item1
Item2
Item3
)
searchItem := "Item3"
Loop, parse, items, `n
{
CurrentItem := A_LoopField
if (CurrentItem = searchItem)
goto MyLabel
}
MyLabel:
MsgBox, % "Do something"
return
|
RegEx is for pattern matching, but I don't see any pattern to match. If you give more details, I could be of more help. _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
strictlyfocused02
Joined: 21 Jan 2009 Posts: 45
|
Posted: Thu Mar 12, 2009 6:44 am Post subject: |
|
|
| animeaime wrote: | | Can you give some example "haystacks"? |
Heres a direct snippet of my logfile thats being read
| Code: | AX26
%%%%%%%%%%% OPCOM 12-MAR-2009 04:11:28.68 %%%%%%%%%%% (from node AX25 at 12-MAR-2009 04:11:28.49)
Request 3248069, from user BBSSYST on AX25
"*** FTP transfer WPTAWWW_HOURLY_MG could not log in ***"
AX26
%%%%%%%%%%% OPCOM 12-MAR-2009 04:48:25.15 %%%%%%%%%%% (from node AW1 at 12-MAR-2009 04:48:24.85)
Request 3247479, from user SYSTEM on AW1
"%GETS_F_EVENT-EMAIL PProblem with GETS fax transmission, check SLOG:[GETS]EVENT_EMAIL_ERR_2009-03-11.LOG"
AX26
%%%%%%%%%%% OPCOM 12-MAR-2009 04:54:26.94 %%%%%%%%%%% (from node AX36 at 12-MAR-2009 04:54:26.92)
Request 3248127, from user SYSTEM on AX36
"*** Job INFOSPACE_RAD_BATCH_FTP_00_00 on queue OUT_FTP_AX23 has duplicates running ***
Investigate and escalate problem if necessary"
AX26
%%%%%%%%%%% OPCOM 12-MAR-2009 04:54:41.59 %%%%%%%%%%% (from node AX22 at 12-MAR-2009 04:54:41.58)
Request 3248132, from user BBSSYST on AX22
"*** Error during BELLTELE_SVR FTP transfer. ***"
AX26
%%%%%%%%%%% OPCOM 12-MAR-2009 06:31:29.36 %%%%%%%%%%% (from node AX16 at 12-MAR-2009 06:31:29.35)
Message from user SYSTEM on AX16
FAX_FEEDBACK, restarting after unexpected exit; restart count = 116
AX26
%%%%%%%%%%% OPCOM 12-MAR-2009 06:32:23.62 %%%%%%%%%%% (from node AX30 at 12-MAR-2009 06:32:23.61)
Request 3248251, from user BBSSYST on AX30
"*** FTP transfer WKBWTV_HOURLY_MG could not log in ***"
|
| animeaime wrote: | | Also, why not use InStr instead (or can't you)? |
I played around with using InStr() but I kept getting false positives. For example, InStr(CurrentOPCOM,"could not log in") would give me a match for anything that had the word "in" inside of it, which could end up being a boat load of things.
| animeaime wrote: | Also, what are you using the RegEx for? Is it that you have a list of items and you need to see if the specific item matches one of them? If so, a continuation block combined with a parse loop would be cleaner code.
RegEx is for pattern matching, but I don't see any pattern to match. If you give more details, I could be of more help. |
I used RegExMatch since it seemed to do what I wanted the best of all the possible ways to do it that I actually understood or was able to make work.
I just need to match certain terms from each haystack (usually the last 7 lines of the log) as it appears in the log. There indivdual names of whatever generated the OPCOM will change (ie GEOMICRO_LIGHTNING, INFOSPACE, etc) but there are certain terms I will always want to look for (FTP transfer XXXX could not log in). I need it to avoid false positives more so than anything. It would be OK to consistently miss one or 2 occurences of something if it was at the cost of avoiding even a single false positive.
Heres my full script (some of it was trimmed due to senstive data )as of this post. Im going to play around with your suggestions of a continuation block and parsing loop and see what I can work up (thanks for the example btw ... I learn by example so it helps more than you can imagine!)
| Code: |
;; -------------------------- Enviroment --------------------------
Process Priority,,High
SetBatchLines -1
#NoEnv
SendMode, Input
SetWorkingDir, %A_ScriptDir%
SetTitleMatchMode, 2
;; -------------------------- Enviroment --------------------------
;; -------------------------- Variables --------------------------
AX26log = %A_ScriptDir%\ax26.log
username = myusername
password = mypassword
;; -------------------------- Variables --------------------------
;; -------------------------- Launch PuTTY --------------------------
;Check for existing PuTTY window
IfWinNotExist,PuTTY
{
;Delete existing PuTTY logs
FileDelete, %AX26log%
;Run the PuTTY executable
Run, %A_ScriptDir%\PuTTYPortable.exe -load "ax26"
;Check the log file for the login prompt every 100ms
Loop {
If (RegExMatch(Tail(7,AX26log),"i)Please Sign On"))
break
Sleep, 100
}
;Send the login name
ControlSend,ahk_parent,%username%{Return},PuTTY
;Check the log file for the password prompt every 100ms
Loop {
If (RegExMatch(Tail(7,AX26log),"i)Password"))
break
Sleep, 100
}
;Send the password
ControlSend,ahk_parent,%password%{Return},PuTTY
;Wait for key buffer then activate and refresh OPCOMs
Sleep, 500
ControlSend,ahk_parent,{NumPadMult},PuTTY
Sleep, 100
ControlSend,ahk_parent,{NumLock},PuTTY
}
;; -------------------------- Launch PuTTY --------------------------
;; -------------------------- Meat and Potatoes --------------------------
;Watch the log file for OPCOMS that match this criteria
Loop {
CurrentOPCOM := Tail(7,AX26log)
If (RegExMatch(CurrentOPCOM,"i)FTP transfer.*could not log in"))
GoSub, AnswerOPCOM
else if (RegExMatch(CurrentOPCOM,"i)FTP transfer.*had a 5xx error during transfer"))
GoSub, AnswerOPCOM
else if (RegExMatch(CurrentOPCOM,"i)Error during.*FTP Transfer"))
GoSub, AnswerOPCOM
else if (RegExMatch(CurrentOPCOM,"i)Job.*on queue.*has duplicates running"))
GoSub, AnswerOPCOM
}
;Extract request code from the OPCOM, reply to it, and refresh OPCOMs
AnswerOPCOM:
FindRequest := RegExMatch(CurrentOPCOM,"Request\s+\K\d+",Request_Code)
ControlSend,ahk_parent,{NumPadsub}%Request_Code%,PuTTY
ControlSend,ahk_parent,{Return},PuTTY
ControlSend,ahk_parent,{NumLock},PuTTY
Sleep, 500
Return
;; -------------------------- Meat and Potatoes --------------------------
;Function for pulling logfile tail
Tail(k,file) ;by Laszlo
{
Loop Read, %file%
{
i := Mod(A_Index,k)
L%i% = %A_LoopReadLine%
}
L := L%i%
Loop % k-1
{
IfLess i,1, SetEnv i,%k%
i-- ; Mod does not work here
L := L%i% "`n" L
}
Return L
}
|
|
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1046
|
Posted: Thu Mar 12, 2009 7:02 am Post subject: |
|
|
The examples you gave all seem to have this form "*** YourText ***". Do all of them have this form? Is so, then you can cut down your work big time. Use the regex "\Q***\E.*\Q***\E". The "\Q ... \E" treats what's between as literal text.
| strictlyfocused02 wrote: | | I played around with using InStr() but I kept getting false positives. For example, InStr(CurrentOPCOM,"could not log in") would give me a match for anything that had the word "in" inside of it, which could end up being a boat load of things. |
No, that function call will get all strings that contain "could not log in". Are there other lines (ones you don't want to match) that contain this text?
Another question, supposing that you can't shorten the load, what form is the stuff that would fit where ".*" is in the RegEx? Are they words, numbers, alphanum (including "_")? It is bad RegEx form to use ".*" casually because it's very expensive - due to backtracing. Also, if you must use it, ".*?" would yield better results. The "?" is a lazy quantifier. It means that instead of matching everything and then back-tracing, it matches character by character and tries to move forward. It's more efficient because the .* only replaces a small part of the string, so it will be quicker. Check RegEx - QuickRef -> Greeed for more information. _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
strictlyfocused02
Joined: 21 Jan 2009 Posts: 45
|
Posted: Thu Mar 12, 2009 9:47 am Post subject: |
|
|
| animeaime wrote: | | The examples you gave all seem to have this form "*** YourText ***". Do all of them have this form? Is so, then you can cut down your work big time. Use the regex "\Q***\E.*\Q***\E". The "\Q ... \E" treats what's between as literal text. |
No, I just didnt happen to notice the ones I copied had that pattern
Heres an example of one that doesnt follow | Code: | %%%%%%%%%%% OPCOM 12-MAR-2009 08:10:15.79 %%%%%%%%%%% (from node AX12 at 12-MAR-2009 08:10:15.80)
Request 3248386, from user SYSTEM on AX12
"ERROR WHILE DOING @COM:[CLIENT]LCW_BSOSTALCW_CURRENT.COM
LOOK AT SLOG:[WEATHER]LCW_BSOSTALCW_HOURLY FOR THE ERROR"
|
| animeaime wrote: | | No, that function call will get all strings that contain "could not log in". Are there other lines (ones you don't want to match) that contain this text? |
Ahh you're right! I restested it and it does work. I may have missed the quotes in my original script.
Ive tried searching through the documentation and havent found anything yet, but is it possible to have wildcard characters in InStr()? For example, I need to look for an occurance where there was an error during whatever FTP transfer. If I say "InStr(CurrentOPCOM,"Error during") or "InStr(CurrentOPCOM,"FTP Transfer") Im going to get a lot of false positves. Ideally this would be the code "If InStr(CurrentOPCOM, FTP Transfer * could not login)"
| animeaime wrote: | | Another question, supposing that you can't shorten the load, what form is the stuff that would fit where ".*" is in the RegEx? Are they words, numbers, alphanum (including "_")? It is bad RegEx form to use ".*" casually because it's very expensive - due to backtracing. Also, if you must use it, ".*?" would yield better results. The "?" is a lazy quantifier. It means that instead of matching everything and then back-tracing, it matches character by character and tries to move forward. It's more efficient because the .* only replaces a small part of the string, so it will be quicker. Check RegEx - QuickRef -> Greeed for more information. |
It can be any combination of alphanumeric, letters, special chars like "-", "*", etc. Im going to play around with using ? and post my results.
Thanks for all the awesome advice so far, you've been a huge help  |
|
| Back to top |
|
 |
strictlyfocused02
Joined: 21 Jan 2009 Posts: 45
|
Posted: Thu Mar 12, 2009 10:15 am Post subject: |
|
|
Wow, I just found the InStrX() function written by Titan. It does the InStr() search perfectly for my purposes and it accepts * for multiple wildcards and ? for single wildcards!
http://www.autohotkey.com/forum/topic11129.html
Heres an example out of my code
| Code: | If InStrX(CurrentOPCOM,"FTP transfer * could not log in")
GoSub, AnswerOPCOM |
Im still hoping to find a better way to do this than having 100+ instances of InStrX() though. |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1046
|
Posted: Thu Mar 12, 2009 5:02 pm Post subject: |
|
|
Not sure... it sounds like there is no overlap - you are just looking for a bunch of strings. So, I think a continuation block of the lines to test, and a parse loop is your best bet. You might, depending how often you use them, want to use StringSplit and loop through the split version (instead of parsing it each time) - not sure if it's faster, just an idea. _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
strictlyfocused02
Joined: 21 Jan 2009 Posts: 45
|
Posted: Sun Mar 29, 2009 5:50 am Post subject: |
|
|
I noticed that my current iteration of the script was eating up about 50% of the CPU on a Core 2 Duo machine So I set out to optimize it a bit and reduce CPU usage as much as possible while still keeping performance. Heres what I came up with. | Code: | Loop {
Y := GetLogLength(AX26log)
If Y != %Z%
{
Z := GetLogLength(AX26log)
GoSub,FindOPCOMType
}
Else
Sleep,10
}
;Determine OPCOM type
FindOPCOMType:
CurrentOPCOM := Tail(7,AX26log)
;FTP Connection Issues
If InStrX(CurrentOPCOM,"FTP transfer * could not log in")
GoSub,AnswerOPCOM
else if InStrX(CurrentOPCOM,"FTP transfer * had a 5xx error during transfer")
GoSub,AnswerOPCOM
else if InStrX(CurrentOPCOM,"FTP transfer * had a 4xx error during transfer")
GoSub,AnswerOPCOM
else if InStrX(CurrentOPCOM,"Error during * FTP Transfer")
GoSub,AnswerOPCOM
else if InStrX(CurrentOPCOM,"FTP transfer * had an fatal error * during transfer")
GoSub,AnswerOPCOM
else if InStrX(CurrentOPCOM,"FTP transfer * had an error (FTP-E) during transfer")
GoSub,AnswerOPCOM
;Quantity or Duration of batch jobs
else if InStrX(CurrentOPCOM,"Job * on queue * has duplicates running")
GoSub,AnswerOPCOM
else if InStrX(CurrentOPCOM,"Job * on queue * may be running for over an hour and a half")
{
GoSub,KillLongJob
GoSub,AnswerOPCOM
}
else if InStrX(CurrentOPCOM,"Job * on queue * has been running for over THREE HOURS")
{
GoSub,KillLongJob
GoSub,AnswerOPCOM
}
Return
GetLogLength(logfile)
{
Loop Read,%logfile%
{
LogLineCount := A_Index
}
Return,LogLineCount
} |
So basically it sits and waits for lines to be added to the log file (with a small wait '10ms' between checks) and then it does all the CPU intensive stuff like finding out what has changed and what needs done based on that.
Edit - Forgot to mention, I now sit at about 5% CPU utilization on a Core 2 machine. I also removed SetBatchLines,-1 which helped a lot. |
|
| Back to top |
|
 |
animeaime
Joined: 04 Nov 2008 Posts: 1046
|
Posted: Sun Mar 29, 2009 6:10 am Post subject: |
|
|
Is there a question? - do you need assistance? _________________ As always, if you have any further questions, don't hesitate to ask.
Add OOP to your scripts via the Class Library. Check out my scripts. |
|
| Back to top |
|
 |
nick
Joined: 24 Aug 2005 Posts: 499 Location: Berlin / Germany
|
Posted: Sun Mar 29, 2009 11:04 am Post subject: |
|
|
Maybe you want to try FileTail(). It returns new lines of a file from the second call on, if some exist.
At the moment your script performs an endless reading of the logfile and is getting slower the longer the logfile is growing.  _________________ nick
denick @ http://de.autohotkey.com/forum/ |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 4367 Location: Qld, Australia
|
Posted: Sun Mar 29, 2009 12:07 pm Post subject: |
|
|
It might be more efficent (but not necessarily more maintainable) to eliminate the common parts and let RegExMatch do the rest. For instance, the regular expression
| Code: | | i)FTP transfer .*? (?:could not log in|had a(?: [45]xx error during transfer|n fatal error .*?|n error \(FTP-E\)) during transfer) |
Matches any of the following:
| Code: | FTP transfer * could not log in
FTP transfer * had a 5xx error during transfer
FTP transfer * had a 4xx error during transfer
FTP transfer * had an fatal error * during transfer
FTP transfer * had an error (FTP-E) during transfer
| At the very least, using regex alternation would likely perform better than a bunch of if/else ifs. For instance,
| Code: | regex=
( Join|
FTP transfer .*? could not log in
FTP transfer .*? had a [54]xx error during transfer
FTP transfer .*? had an fatal error .*? during transfer
FTP transfer .*? had an error \(FTP-E\) during transfer
)
if RegExMatch(CurrentOPCOM,regex)
...
|
| nick wrote: | | Maybe you want to try FileTail(). | Looks interesting, thanks nick. |
|
| Back to top |
|
 |
strictlyfocused02
Joined: 21 Jan 2009 Posts: 45
|
Posted: Thu Apr 02, 2009 11:11 am Post subject: |
|
|
| nick wrote: | Maybe you want to try FileTail(). It returns new lines of a file from the second call on, if some exist.
At the moment your script performs an endless reading of the logfile and is getting slower the longer the logfile is growing.  |
Im probably missing something simple here but how had you figured I could implement this into my existing script?
Read only the changed lines or reading the whole file to check to see if anything has been added to it? |
|
| Back to top |
|
 |
strictlyfocused02
Joined: 21 Jan 2009 Posts: 45
|
Posted: Wed Apr 08, 2009 10:04 am Post subject: |
|
|
| nick wrote: | At the moment your script performs an endless reading of the logfile and is getting slower the longer the logfile is growing.  |
I would still like to find a solution to this ... as it stands it gets pretty bogged down when the log file reaches about 1.5mb.
I looked at FileRead, but when it runs it locks the file and then PuTTY cant continue writing to the log as OPCOMs are posted.
Do DllCalls lock file the same way? Loop,Read does not lock the file and would be perfect except my log file gets pretty huge after 2-3 hours ... |
|
| Back to top |
|
 |
nick
Joined: 24 Aug 2005 Posts: 499 Location: Berlin / Germany
|
Posted: Wed Apr 08, 2009 3:02 pm Post subject: |
|
|
Well, here's some example, how it may work:
| Code: | ;; -------------------------- Test ---------------------------------------------
OPCOM =
(% Join`r`n
AX26
%%%%%%%%%%% OPCOM 12-MAR-2009 04:11:28.68 %%%%%%%%%%% (from node AX25 at 12-MAR-2009 04:11:28.49)
Request 3248069, from user BBSSYST on AX25
"*** FTP transfer WPTAWWW_HOURLY_MG could not log in ***"
AX26
%%%%%%%%%%% OPCOM 12-MAR-2009 04:48:25.15 %%%%%%%%%%% (from node AW1 at 12-MAR-2009 04:48:24.85)
Request 3247479, from user SYSTEM on AW1
"%GETS_F_EVENT-EMAIL PProblem with GETS fax transmission, check SLOG:[GETS]EVENT_EMAIL_ERR_2009-03-11.LOG"
AX26
%%%%%%%%%%% OPCOM 12-MAR-2009 04:54:26.94 %%%%%%%%%%% (from node AX36 at 12-MAR-2009 04:54:26.92)
Request 3248127, from user SYSTEM on AX36
"*** Job INFOSPACE_RAD_BATCH_FTP_00_00 on queue OUT_FTP_AX23 has duplicates running ***"
Investigate and escalate problem if necessary"
AX26
%%%%%%%%%%% OPCOM 12-MAR-2009 04:54:41.59 %%%%%%%%%%% (from node AX22 at 12-MAR-2009 04:54:41.58)
Request 3248132, from user BBSSYST on AX22
"*** Error during BELLTELE_SVR FTP transfer. ***"
AX26
%%%%%%%%%%% OPCOM 12-MAR-2009 06:31:29.36 %%%%%%%%%%% (from node AX16 at 12-MAR-2009 06:31:29.35)
Message from user SYSTEM on AX16
FAX_FEEDBACK, restarting after unexpected exit; restart count = 116
AX26
%%%%%%%%%%% OPCOM 12-MAR-2009 06:32:23.62 %%%%%%%%%%% (from node AX30 at 12-MAR-2009 06:32:23.61)
Request 3248251, from user BBSSYST on AX30
"*** FTP transfer WKBWTV_HOURLY_MG could not log in ***"
)
FileDelete, ax26.log
FileAppend, %OPCOM%, ax26.log
SetTimer, WriteLog, 5000
;; -------------------------- Test ---------------------------------------------
;; -------------------------- Enviroment ---------------------------------------
#NoEnv
SetBatchLines -1
SendMode, Input
SetWorkingDir, %A_ScriptDir%
SetTitleMatchMode, 2
;; -------------------------- Enviroment ---------------------------------------
#Include FileTail.ahk
;; -------------------------- Variables ----------------------------------------
AX26log = %A_ScriptDir%\ax26.log
username = myusername
password = mypassword
Tail := ""
;; -------------------------- Variables ----------------------------------------
;; -------------------------- Test ---------------------------------------------
GoTo, Watch
;; -------------------------- Test ---------------------------------------------
;; -------------------------- Launch PuTTY -------------------------------------
;Check for existing PuTTY window
IfWinNotExist,PuTTY
{
;Delete existing PuTTY logs
FileDelete, %AX26log%
;Run the PuTTY executable
Run, %A_ScriptDir%\PuTTYPortable.exe -load "ax26", , , PID
WinWaitActive, ahk_pid %PID%
Tail := FileTail(AX26log)
;Check the log file for the login prompt every 100ms
Loop {
If (RegExMatch(Tail,"i)Please Sign On"))
Break
Sleep, 100
Tail := FileTail(AX26log)
}
;Send the login name
ControlSend,ahk_parent,%username%{Return},PuTTY
;Check the log file for the password prompt every 100ms
Loop {
If (RegExMatch(Tail,"i)Password"))
Break
Sleep, 100
Tail := FileTail(AX26log)
}
;Send the password
ControlSend,ahk_parent,%password%{Return},PuTTY
;Wait for key buffer then activate and refresh OPCOMs
Sleep, 500
ControlSend,ahk_parent,{NumPadMult},PuTTY
Sleep, 100
ControlSend,ahk_parent,{NumLock},PuTTY
}
;; -------------------------- Launch PuTTY -------------------------------------
;; -------------------------- Meat and Potatoes --------------------------------
;Watch the log file for OPCOMS that match this criteria
Watch:
If (Tail = "") ; FileTail hasn't been called yet
FileTail(AX26log)
CurrentOPCOM := Tail
Request_Code := ""
Loop {
Loop, Parse, CurrentOPCOM, `n
{
If (Request_Code) {
If RegExMatch(A_LoopField, "iS)FTP transfer.*?could not log in")
Or RegExMatch(A_LoopField, "iS)FTP transfer.*?had a 5xx error during transfer")
Or RegExMatch(A_LoopField, "iS)Error during.*?FTP Transfer")
Or RegExMatch(A_LoopField, "iS)Job.*?on queue.*?has duplicates running")
GoSub, AnswerOPCOM
Request_Code := ""
} Else {
RegExMatch(A_LoopField, "iS)^Request\s+\K\d+", Request_Code)
}
}
Sleep, 500
CurrentOPCOM := FileTail(AX26log)
}
; Reply to the request and refresh OPCOMs
AnswerOPCOM:
MsgBox, %Request_Code%
Return
ControlSend,ahk_parent,{NumPadsub}%Request_Code%,PuTTY
ControlSend,ahk_parent,{Return},PuTTY
ControlSend,ahk_parent,{NumLock},PuTTY
Sleep, 500
Return
;; -------------------------- Meat and Potatoes --------------------------------
;; -------------------------- Test ---------------------------------------------
WriteLog:
FileAppend, %OPCOM%, ax26.log
Return
;; -------------------------- Test ---------------------------------------------
|
But I'm not shure, because I couldn't really test it. _________________ nick
denick @ http://de.autohotkey.com/forum/ |
|
| Back to top |
|
 |
strictlyfocused02
Joined: 21 Jan 2009 Posts: 45
|
Posted: Thu Apr 09, 2009 5:44 am Post subject: |
|
|
| nick wrote: | Well, here's some example, how it may work:
But I'm not shure, because I couldn't really test it. |
Thank you,nick, that is exactly what I was looking for. I will play around with it tonight and post back with my results! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|