|
Post by griffler on Mar 20, 2023 23:56:00 GMT
Hello all, I'm wanting to tail a log file and if it matches a string have it goto a certain part of my script.
I've read several different operators and just keep confusing myself more and more. What would be the best way to go about filtering the tail of a log file and acting upon those results? I've considered appending the log file down to only the content I need and reading that file with MMM, etc. Just cant decide where and how to pull the trigger.
Thanks for your help!
|
|
|
Post by griffler on Mar 21, 2023 1:02:32 GMT
I've got a powershell script running that appends the log file down to only the lines that I'll need the script reacting to. Now I just need help figuring out how to read each line added to the new appended log file and react to each.
|
|
|
Post by zeak on Mar 21, 2023 6:52:00 GMT
Hi Griffler, Does the following code work for your case? 1 | IF | FILE | C:\rescue.log | FILE CONTAINS STRING | error | KILL PROCESS ID | 8732 This reads - IF the FILE c:\rescue.log FILE CONTAINS STRING 'error' then KILL PROCESS ID 8732. So if the file c:\rescue.log contains the text string 'error' anywhere in the file then kill the current running process with the process ID of 8732. www.turnssoft.com/conditions.html#filecontainsstring
|
|
|
Post by zeak on Mar 21, 2023 7:17:35 GMT
Another method would be to monitor the log file for changes. 1 | RUN ACTION | INPUT FROM FILE | STRING::REFRESH::C:\Users\Zeak\Documents\Calculators\Macros\TestFile.txt 2 | IF | STRING VARIABLE | %STRING% | CONTAINS -C | error | CONTINUE www.turnssoft.com/conditions.html#inputfromfilewww.turnssoft.com/conditions.html#containscIf you would like it to be even more actuate, then use your PowerShell script to put in the variable handles and use the INPUT FROM FILE | VARIABLES part of the condition. If you need any more help, don't hesitate to ask. Cheers, Zeak
|
|
|
Post by griffler on Mar 21, 2023 8:15:40 GMT
Amazing, thanks for the help! I had considered your first suggestion, it is a constantly updating log file, so I think the second route might be the way to go? I can match each line in the powershell append and assign a variable. Should the variable be at the end or beginning of each line, and how should the variable be formatted? What I'll then be shooting for is each time a new line is added at the end of the append file, it will trigger the script accordingly.
Thanks again for your time!
|
|