Mein Skript SSH in einen HP-Schalter und macht eine Schnittstelle zu ändern. Ich kann nicht herausfinden, was die fehlerhaften Zeichen in der Ausgabe verursacht (siehe fett).erwarten Skript hat fehlerhafte Zeichen
Mein Skript:
#!/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
Siehe fehlerhafte Ausgabe unter: ; 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$
Die 'einfache Lösung' verursacht immer noch fehlerhafte Ausgabe. Ich werde Stripping esc Seq untersuchen. Jede andere Eingabe wird geschätzt. – randydrobinson
Sie sollten sehen, was passiert, wenn Sie Ihre erwarteten Skriptsteuersequenzen senden. 'ssh' in localhost und führe ein Skript aus, das Echos ähnlich dem Router ausgibt und Echos wie CPR-Sequenzen zurückgibt. –
gibt es ein Programm namens vltest, dass Sie in dieser Situation hilfreich sein können. –