Say I have two bash scripts (p1.sh and p2.sh), representing two programs:
#!/bin/bash
echo "hello"
sleep 10s
echo "good morning"
sleep 10s
echo "goodbye !!"
And p2.sh:
#!/bin/bash
# listen to the output of p1's program
# if p1 gives "goodbye !!" output, echo "p1 said goodbye!"
The workflow is:
- Run
p1.sh - Get the pid of the
p1program - Let
p2.shlisten to thep1process's output (instead of callingp1.shinside ofp2.sh), and judgep1's output.
How to realize it? Thanks!