title: Pexpect and GRUB - Why is Pexpect showing me a blank GRUB menu?
body: <p>I am attempting to script a reboot of a system and I have several GRUB entries.  Pexpect doesn't seem to "see" the menu items.</p>
  
  <p>Here is a code snippet:</p>
  
  <pre><code>def get_menu_selections(xtn):
      print "Waiting for GNU GRUB to show"
      xtn.expect_exact("GNU GRUB", timeout=480)
      time.sleep(3)
      xtn.expect_exact('Use the ^ and v keys')
      print xtn.before
      print xtn.after
  
  def main():
      connection = pexpect.spawn('ssh -l user -p2288 1.2.3.4')
      # reboot box
      get_menu_selections(connection)
  
  main()
  </code></pre>
  
  <p>To explain why my snippet is like it is: Once "GNU GRUB" is on the screen, then my timeout stops, which means the wait for the system to reboot is over.  At that point, I am guessing that GRUB draws the box, then fills it in, so I'm sleeping 3 seconds to wait for the content of the GRUB menu to be drawn on the screen.  After I wait, then I was going to match on "Use the ^ and v keys" as my match so I can get a before and after.</p>
  
  <p>This is what my GRUB looks like:</p>
  
  <pre><code>                  GNU GRUB  version 1.98+20100804-14+squeeze1
  
   +--------------------------------------------------------------------------+
   |Base OS                                                                   |
   |Base OS -&gt; ttyS0                                                          |
   |Base OS (recovery mode)                                                   |
   |Base OS -&gt; ttyS0 (recovery mode)                                          |
   |System Rescue                                                             |
   |System Rescue -&gt; ttyS0                                                    |
   |                                                                          |
   +--------------------------------------------------------------------------+
  
    Use the ^ and v keys to select which entry is highlighted.
    Press enter to boot the selected OS, 'e' to edit the commands
    before booting or 'c' for a command-line.
  
    The highlighted entry will be executed automatically in 0s.
  </code></pre>
  
  <p>Instead of seeing the menu items, I'm only seeing the drawn outline and the text at the bottom.  This is what my code prints to the screen:</p>
  
  <pre><code>+--------------------------------------------------------------------------+     
  |                                                                          |
  |                                                                          |
  |                                                                          |
  |                                                                          |
  |                                                                          |
  +--------------------------------------------------------------------------+
  
  Use the ^ and v keys
  </code></pre>
  
  <p>I'd like to get the menu options into a buffer ("before", "match", or "after") so that I can take inventory.  Any idea how to grab the menu items?</p>