title: linux pipe with multiple programs asking for user input
body: <p>I wonder how to create a pipe </p>
  
  <pre><code>program 1 | ... | program N
  </code></pre>
  
  <p>where multiple of the programs ask for user input. The problem is that <code>|</code> starts the programs in parallel and thus they start reading from the terminal in parallel.</p>
  
  <p>For such cases it would be useful to have a pipe <code>|</code> that starts program (i+1) only after program i has produced some output.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Example:</p>
  
  <pre><code>cat /dev/sda | bzip2 | gpg -c | ssh user@host 'cat &gt; backup'
  </code></pre>
  
  <p>Here both <code>gpg -c</code> as well as <code>ssh</code> ask for a password.</p>
  
  <p>A workaround for this particular example would be the creation of ssh key pairs, but this is not possible on every system, and I was wondering whether there is a general solution. 
  Also gpg allows for the passphrase to be passed as command line argument, but this is not suggested for security reasons.</p>