expect -re "(enable\\) \*$)|(> *\ *$)|(# *\ *$)"
????
what i want to do next --> if the prompt ends in either '(enable)',
'>', or '#', assign it to the variable "login".
????
switch -- $login {
"> *\ *$" {
send "en\r"
expect "ssword"
send "$password\r"
send "config t\r"
}
"enable\\) \*$" {
send "\n\r"
}
"# *\ *$" {
send "config t\r"
}
default {
send " \n"
}
}
Also if anyone can see a simpler way this can be done I'd appreciate
it. Definitely trying to use Expect/tcl to make my work assignments
easier and bearable. Also a learning opportunity.
with the following
expect {
-re "> *\ *$" {
send "en\r"
expect "ssword"
send "$password\r"
send "config t\r"
}
-re "enable\\) \*$" {
send "\n\r"
}
-re "# *\ *$" {
send "config t\r"
}
timeout {
send " \n"
}
}
Bruce
Thanks Bruce. Your alternative works for me and straight forward.
Jeff