【发布时间】:2015-10-28 14:08:34
【问题描述】:
我有以下脚本,它们应该从文件device-list.txt 中提取 IP 地址,然后 telnet 到设备,登录并执行显示运行。该脚本成功登录到设备,但之后给了我一个错误。任何想法我哪里出错了?
for device in `cat device-list.txt`; do ./test4 $device;done
cat test4
#!/usr/bin/expect -f
set hostname [lindex $argv 0]
set user myusername
set pass mypassword
set timeout 10
log_file -a ~/results.log
send_user "\n"
send_user ">>>>> Working on $hostname @ [exec date] <<<<<\n"
send_user "\n"
spawn telnet $hostname
expect "Username:"
send "$user\n"
expect "Password:"
send "$pass\n"
expect "#"
send “term len 0\n”
send “show running-config\n”
expect “end\r”
send “\n”
send “exit\n”
User Access Verification
Username: myusername
Password:
ROUTER#usage: send [args] string
while executing
"send “term len 0\n”"
(file "./test4" line 26)
【问题讨论】:
标签: expect