I have a log file which is auto updated and looks like this:
...
[23:32:19.586] PULL START
[23:32:19.637] PULL RESP NONE
[23:32:22.576] Rx - +CMS ERROR: 29
[23:32:22.686] STAT - TRY 2
[23:32:22.797] Tx - AT+CMGF=1
[23:32:23.008] Rx - OK
[23:32:23.017] Tx - at+cmgs="number"
[23:32:23.428] Rx - >
[23:32:23.438] Tx - message
[23:32:24.675] PULL START
[23:32:24.714] PULL RESP NONE
[23:32:26.663] Rx - +CMS ERROR: 29
[23:32:26.681] STAT - 68$$"+CMS ERROR: 29"
[23:32:26.695] SEND - RESPONSE, TRANS ID = xxxxxxxx, RESP CODE = xx, MESSAGE = +CMS ERROR: 29
and I have a list to be compared which is looks like this:
[
'+CMS ERROR: 8',
'+CMS ERROR: 28',
'+CMS ERROR: 29',
'+CMS ERROR: 50',
'+CMS ERROR: 226',
]
All I want to do is if the last line of the log file has string +CMS ERROR: XX
and matches one from the list, I want to terminate the log related program.
Note that the log file will keep updating at random time as long as the program is running and my program will re-check the log file each seconds. If the updates(the last line printed on the log file) does not contain any of the string on the list, it will not terminate any program.
Is it possible to do that in python? like using regex or something? Please help.