title: Scripting item selection in menu that uses arrows
body: <p>I am attempting to automate some diagnostics using scripts in bash that call programs/scripts that I did not personally write. Many of the scripts have menus based off case switches and read key presses, making it simple to feed in menu selections using a script, like so:</p>
  
  <pre><code>sh foo.sh &lt;&lt;EOF
  0
  0
  1
  EOF
  </code></pre>
  
  <p>However, I have one particular menu that does not appear to be operating on a case switch and instead forces the user to use the arrow keys to select an option indicated with an 'x', followed by the [Enter] key.</p>
  
  <p>When I try to feed in options as above, the menu locks up and I have to ctrl+alt+del to restart this system. The only thing that seems to register is the 'new line', which advances the menu, but only on the first item in the menu. I have tried various escape sequences for the arrow keys, numbers, letters, etc, but to no avail. I have no idea how to create a menu that operates on arrow keys, so I don't have a basis to approach this problem.</p>
  
  <p>To boil this down, I need a way to feed in selections to a menu of this type (whatever type it is), to help prevent the fat-fingering that occurs when simple tasks must be conducted repeatedly, and no feedback exists to ensure correct selection until AFTER a 4 hour test is done.</p>
  
  <p>EDIT: For clarification, this is an older version of Ubuntu running in recovery mode. The program/script under scrutiny is a proprietary diagnostic that is fairly locked down and of an undetermined type or origin. </p>
  
  <p>What I'm hoping to get from here is, if not a solution, a lead in the right direction. As per suggestions, I'm looking into expect/autoexpect, as well as tput.</p>
  
  <p>UPDATE: So after some more investigation, I have discovered this is, in fact, an executable. I don't know if this clarifies my question, or renders what I am trying to do impractical, I'll let the gurus decide. At the very least, I know I'm completely offtrack trying to feed in input the way I originally attempted.</p>