title: Getting a shell script to wait for a specific response from python program
body: <p>I'm trying to write a script that calls a python program, pauses until the program outputs a certain message (not when the program ends), then moves on.</p>
  <p>If I have example.py like this that just runs indefinitely:</p>
  <pre class="lang-py prettyprint-override"><code>doSomething()
  print('I did something')
  doSomethingElseForever()
  </code></pre>
  <p>I want to have a script something like this:</p>
  <pre class="lang-sh prettyprint-override"><code>echo &quot;Running python program&quot;
  python3 example.py &amp;
  waitForOutput(&quot;I did something&quot;)
  echo &quot;Python program did something, it's still running in the background&quot;
  doSomeMoreScriptStuff
  </code></pre>
  <p>Ideally, I would just run the script and it would launch example.py, pause until example.py output &quot;I did something&quot;, then continue on to launch more programs or whatever, without stopping example.py (hence the &amp;).</p>
  <p>I'm working in Ubuntu BTW.</p>
  <p>Edit: I think in my particular application at the moment I could just change my python script to create a file instead of print(), but for the sake of learning (and because that seems like a convoluted way to do things), let's assume I can't edit the python file. So all I have to work with is the known output of a print() statement.</p>