So, due to some very poor design choices I'm stuck with a complex and unreplaceable interactive console application running forever on a Debian machine.
This apps does some tasks, repeatedly, and returns to stdout
results like:
InvetoryOpt: Finished
PBridged: Finished
FLoot: ERROR
I need to make sure that every x minutes I get the string InvetoryOpt: Finished
on the output of the program. If not I need to kill it, run other a script, start the program again and the check.
How may I accomplish this? I was thinking about expect
but I don't have much experience with with and I'm not sure I'm able to check if output matches string every x minutes.
Notes:
- The program also outputs lots of other garbage that I don't care about;
- The program can output the same string
InvetoryOpt: Finished
multiple times in 30 minutes or just don't output anything at all. So tailing the end of a file won't do it because it would match the last output of that string.
Thank you.
You can use the script below as a wrapper-controller. I assume bash is known, so no technical comments. I can add them if you want them.
The variables PROGRAM and OTHER_SCRIPT for the script you mentioned need to be defined.
The time control is rigid, ie. it doesn't reset the countdown to the last
InvetoryOpt: Finished
message time, just checks every 30 mins. I can think of a way to improve this if you need it.UPDATE: Trap added.