0

Is it possible to select options in GRUB menu to select appropriate option to boot the device ?

I have a serial connection to the device and I am writing the expect script to send the DOWNARROW key to select the appropriate option in the GRUB menu at bootup. But for some reason it doesn't work out.

expect "GRUB loading."
#down arrow
send {^[\[B}

send "\r"
send "\r"
codingfreak
  • 4,467
  • 11
  • 48
  • 60

3 Answers3

1

After trying multiple methods of issuing a 'down arrow' with expect, I managed to get this to work using grub2:

send \003N

This sends Ctl+N, which works as a secondary down arrow, seen and explained better here: https://unix.stackexchange.com/questions/137323/grub2-without-arrow-keys

Christian
  • 11
  • 2
0

Since you are using braces, you don't need to escape the [

send -- {^[[B}  ;# where "^[" is entered with ctrl-V Esc

Or using double quotes, where the open bracket does need to be escaped, but it's easier to type the escape character.

send -- "\033\[B"
glenn jackman
  • 238,783
  • 38
  • 220
  • 352
0
send "\033\[B"

works for moving down the menu in grub (\033 is the ESC char)

so then for example

send "\033\[B\033\[B\r"

will move you down twice and then send a carriage return-- choose third option in menu

logi-kal
  • 7,107
  • 6
  • 31
  • 43