I need to know how to write a script that will start two different programs in consoles (S1 and S2) and monitor the output of s2 console in lucid puppy linux.
I need it to monitor the output of the console for a specific pattern (Failed to receive control words) and when it finds the pattern, I need it to kill S2 process and start it back.

Some help looking for maybe a template script or some useful commands for attempting this.
Thank You