1
我的脚本ssh进入HP交换机并改变了界面。我无法弄清楚是什么导致了输出中的错误字符(参见粗体)。期望脚本有错误的字符
我的脚本:
#!/usr/bin/expect
spawn ssh -o StrictHostKeyChecking=no [email protected]
expect {
"password:" { send "passwd\r" ; exp_continue }
"Press any key to continue" { send " \r" ; exp_continue }
"240#" { send "conf t\r" }
}
expect {
"(config)#" { send "int 8\r" }
}
expect {
"(eth-8)#" { send "enable\r" }
}
expect {
"(eth-8)#" { send "wr mem\r" }
}
expect {
"(eth-8)#" { send "end\r" }
}
expect {
"#" { send "logout\r" }
}
expect eof
见下误输出: ; 209R & ; 209R^C
[email protected]:/config/scripts$ ./test_disable.exp
spawn ssh -o StrictHostKeyChecking=no [email protected]
========= WARNING: Unauthorized access to this system is forbidden
and will be prosecuted by law. By accessing this system, you agree
that your actions may be monitored if unauthorized usage is suspected.
===
[email protected]'s password:
Press any key to continue
Your previous successful login (as user) was on 2016-11-18 14:30:54
from <ip removed>
swtch-16-57-240#
swtch-16-57-240# conf t
swtch-16-57-240(config)# int 8;209R
swtch-16-57-240(eth-8)# enable
swtch-16-57-240(eth-8)# wr mem
swtch-16-57-240(eth-8)# end
swtch-16-57-240# logout
Do you want to log out [y/n]? y
Connection to switch closed by remote host.
Connection to switch closed.
[email protected]:/config/scripts$ ;209R^C
[email protected]:/config/scripts$
'简单的解决方案'仍然会导致错误的输出。我会调查剥离esc seq。任何其他输入赞赏。 – randydrobinson
如果您发送期望的脚本控制序列,您应该会看到会发生什么情况。 'ssh'放入本地主机并运行一个与路由器相似的回声输出的脚本,并且还回显像CPR这样的转义序列。 –
有一个名为vttest的程序,您可能会在这种情况下有所帮助。 –