How to use expect with optional prompts?
You can expect multiple things:
expect {
"prompt2" {
send "pass2"
expect "prompt3"
send "pass3"
}
"prompt3" {
send "pass3"
}
}
As long as you have a case that will be always be expected to hit and don't include an exp_continue
in that case, you can can remove duplication and handle optional prompts easily:
expect "prompt1"
send "pass1"
expect {
"prompt2" {
send "pass2"
exp_continue
}
"prompt3" {
send "pass3"
}
}