title: bash script, control processes with stdin/stdout
body: <p>Please help to advise how to use bash to catch the sub-process's stdout and send character to sub-process's stdin.</p>
  
  <p>For example, use bash to control 10 videos convert by ffmpeg process, bash code needs to watch each ffmpeg process's stdout then decides if send the stdin command <code>[+]</code>/<code>[-]</code>/<code>[c]</code>/<code>[q]</code> or others command to control ffmpeg</p>
  
  <p>the covert job would be something like</p>
  
  <pre><code>ffmpeg -i INPUT_n -c copy -f flv out_n.flv 2&gt;&amp;1 | grep "[MY_PATTERN]"
  </code></pre>
  
  <p>only when [MY_PATTERN] occurs this job shows word on it's stdout. 
  I would like to use bash code to catch the job's stdout, do some decision according to the line included MY_PATTERN then feed command into the job's stdin.
  I guess I need to active new shell by bash to execute the job and interact its stdin/stdout. But how to ?</p>