expect - multiple lines
Hi, I'm trying to automate access to a switch with expect.
What happens is that login is successful but after login the switch sends to the terminal a message
Enable privilege granted.
switch1#
Aug 2 10:58:05 switch1 NOTICE mgmt: user(admin) login from host 123.123.123.123
So I should expect 5 lines: the first matches "Enable privilege granted", then a blank line, then "switch1#", then the long message, and finally an empty line where the curor blinks.
I tried to match any sort of characters, but I suspect that the culprit is the last empty line.
The outcome is that either the script times out because it matches nothing or that it exits.
Any suggestion?
I attach one of the many versions of the script.
Pier
#!/usr/bin/expect
#exp_internal 1
spawn telnet 10.2.3.4
expect "Enter tacacs username:"
send "user\r"
expect "Enter tacacs password:"
send "password\r"
expect "#"
send "sh run\r"
send " "
exit
|