2
My Bash 4 script calls a third-party program P
(one that I can't recompile), which prints warnings to STDOUT. When it prints yikes
, it also enters an infinite loop. So when I detect a yikes
, how can I immediately stop P
and return control to my script? (And let P
finish normally otherwise.)
Possibly useful fragments:
(echo $BASHPID > /tmp/subpid; ./P | tee /tmp/Pout ) &
tail -f /tmp/Pout | grep -m1 yikes && kill -9 $(cat /tmp/subpid)
wait
Recent Ubuntus don't include it by default.
sudo apt-get install expect
? – Camille Goudeseune – 2017-10-19T17:43:50.620In my case, after yikes, P prints an infinite number of lines! – Camille Goudeseune – 2017-10-19T17:45:27.153