title: Start background process from shellscript then bring back to foreground later
body: <p>I'm trying to make a shell script that does the following:</p>
  
  <ul>
  <li>Start program x</li>
  <li><p>While x is running execute some commands, for example:</p>
  
  <pre><code>echo "blabla" &gt;&gt; ~/blabla.txt
  </code></pre></li>
  <li><p>After the execution of those commands program x should be running in the foreground, so that it can take user input.</p></li>
  </ul>
  
  <p>So far I have:</p>
  
  <pre><code>~/x &amp;
  echo "blabla" &gt;&gt; ~/blabla.txt
  </code></pre>
  
  <p>However, I don't know how to move x back to the foreground. This is all called from a shell script so I don't know the job number of x to move to the foreground.</p>
  
  <p>Note: everything has to be automated, no user interaction with the shell script should be needed.</p>
  
  <p>Any suggestions are welcome :)</p>