title: PHP Exec command - How to pass input to a series of questions
body: <p>I have a program on my linux server that asks the same series of questions each time it executes and then provides several lines of output.  My goal is to automate the input and output with a php script.</p>
  
  <p> The program  is not designed to accept input on the command line.  Instead, the program asks question 1 and waits for an  answer from the keyboard, then the program asks question 2 and waits for an answer from the keyboard, etc. </p>
  
  <p>I know how to capture the <strong>output</strong> in an array by writing:
  $out = array();
  exec("my/path/program",$out);</p>
  
  <p>But how do I handle the <strong>input</strong>?
  Assume the program asks 3 questions and valid answers are:  left  120  n
  What is the easiest way using php to pass that input to the program?
  Can I do it somehow on the exec line?</p>
  
  <p>I’m not a php noob but simply have never needed to do this before.
  Alas, my googling is going in circles.</p>