Reputation: 9
I have a very simple expect script to connect to a Cisco Wireless Lan Controller via Cisco router. My problem is that after some commands expect stops suddenly without finish all sentences and without any error. I think that the problem is with * from password but I'm not sure. That's my script
#!/usr/bin/expect
set timeout 10
spawn telnet X.Y.Z.W
expect "User Access Verification"
expect "Username:"
send "admin\r"
expect "Password:"
send "PASSWORD\r"
expect "Router#"
send "telnet WLC_IP\r"
expect "(Cisco Controller)"
expect "User:"
send "admin\r"
expect "Password:"
send "PASSWORD\r"
expect "Cisco Controller"
send " config paging disable\r"
expect "Cisco Controller"
send " show ap auto-rf 802.11b AP-NAME\r"
expect "Cisco Controller"
send "logout\r";
And this is the output after running,
spawn telnet X.Y.Z.W
Trying X.Y.Z.W...
Connected to X.Y.Z.W.
Escape character is '^]'.
User Access Verification
Username: admin
Password:
Router#telnet WLC_IP
Trying WLC_IP ... Open
(Cisco Controller)
User: admin
Password:**********
(Cisco Controller) >?
clear Clear selected configuration elements.
config Configure switch options and settings.
cping Send capwap echo packets to a specified mobility peer IP address.
debug Manages system debug options.
eping Send Ethernet-over-IP echo packets to a specified mobility peer IP address.
grep Print lines matching a pattern.
help Help
license Manage Software License
linktest Perform a link test to a specified MAC address.
logout Exit this session. Any unsaved changes are lost.
mping Send Mobility echo packets to a specified mobility peer IP address.
ping Send ICMP echo packets to a specified IP address.
reset Reset options.
save Save switch configurations.
show Display switch options and settings.
test Test trigger commands
transfer Transfer a file to or from the switch.
(Cisco Controller) >config paging disable
(Cisco Controller) >[root@mailman scripts]#
Also, there are an "?" after password that I don't know why is it.
Any ideas?
Thanks in advance!
Upvotes: 0
Views: 242
Reputation: 9
after setting expect eof
at the end of my script it works well! I'm not sure if it's mandatory but works for me.
Thank you!
Upvotes: 0