title: How can I pipe initial input into process which will then be interactive?
body: <p>I'd like to be able to inject an initial command into the launching of an interactive process, so that I can do something like this:</p>
  
  <pre><code>echo "initial command" | INSERT_MAGIC_HERE some_tool
  
  tool&gt; initial command 
  
  [result of initial command] 
  
  tool&gt; [now I type an interactive command]
  </code></pre>
  
  <p>What doesn't work:</p>
  
  <ul>
  <li><p>Just piping the initial command in doesn't work, as this results in stdin not being connected to the terminal</p></li>
  <li><p>Writing to /dev/pts/[number] sends the output to the terminal, not input to the process as if it were from the terminal</p></li>
  </ul>
  
  <p>What would but with disadvantages:</p>
  
  <ul>
  <li><p>Make a command which forks a child, writes to its stdin and then forwards everything from its own stdin.  Downside - terminal control things (like line vs character mode) won't work.  Maybe I could do something with proxying of pseudo terminals?</p></li>
  <li><p>Make a modified version of xterm (I'm launching one for this task anyway) with a command line option to inject additional commands after encountering a desired prompt string.  Ugly.</p></li>
  <li><p>Make a modified version of the tool I'm trying to run so that it accepts an initial command on the command line.  Breaks the standard installation.</p></li>
  </ul>
  
  <p>(The tool of current interest, incidentally, is android's adb shell - I want to open an interactive shell on the phone, run a command automatically, and then have an interactive session)</p>