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
expect 스크립트 제어 시퀀스를 보내면 어떻게 될지 알아야합니다. 'ssh'를 localhost에 넣고 라우터와 비슷한 결과를 출력하는 스크립트를 실행하고 CPR과 같은 이스케이프 시퀀스를 반영합니다. –
이 상황에서 도움이 될 수있는 vttest라는 프로그램이 있습니다. –