I'm working on an Expect script for pulling configuration information from my hosts.
The problem is that some of my hosts (when the enable command is entered) will prompt for both a login and password. This is mostly older HP kit but I've run into it elsewhere as well.
A nested expect statement like the following would do it if it were legal syntax. How can I make this happen?
expect {
default { send_user "\nEnable Mode Failed - Check Password\n"; exit 1 }
"*\#" {}
"*>" {
send "enable\n"
expect{
"Login" {
send "$username\n"
}
default {}
}
expect "*assword"
send "$enablepassword\n"
expect "*\#"
}
}
I know I have the syntax only slightly off - I've seen plenty of references that describe using nested expects - but for the life of me I can't quite get it.