2016-10-13 41 views
0

我有一個非常簡單的期望腳本通過Cisco路由器連接到思科無線局域網控制器。 我的問題是,一些命令後,期望突然停止沒有完成所有句子,沒有任何錯誤。 我認爲問題是*來自密碼,但我不確定。 這是我的腳本bash預計在***之後停止

#!/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"; 

這是運行後的輸出,

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) >[[email protected] scripts]# 

此外,還有一個 「?」密碼後我不知道爲什麼。

任何想法?

提前致謝!

+0

你真的需要'發送'配置分頁禁用\ r「'開頭的空格嗎?我認爲這可能會觸發命令完成。 – Barmar

+0

我想這個問題可能更適合http://superuser.com/ – Sufian

+0

空間不是必需的,只是一個測試,我有相同的行爲與空間或沒有它。 –

回答

0

設置expect eof在我的腳本結束後,它運行良好!我不確定這是否是強制性的,但適用於我。

謝謝!