#!/usr/bin/expect
#
spawn grub-md5-crypt
expect "Password:"
send "123123\r"
expect "Retype password:"
send "123123\r"
interact 
或者

密码分两行echo