백업 실행 구성을 설정하고 있는데 원하는 대로 작동하지 않습니다. 데이터를 txt에 어떻게 덤프합니까?
#!/usr/bin/expect -f
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
spawn $env(SHELL)
match_max 100000
expect -exact "example@host:~\$ "
send -- "telnet xxx.xxx.xxx.xxx"
expect -exact "telnet xxx.xxx.xxx.xxx"
send -- "\r"
expect -exact "\r
Trying 180.xxx.xxx.xxx...\r
Connected to 180.xxx.xxx.xxx.\r
Escape character is '^\]'.\r
\r
\r
User Access Verification\r
\r
Username: "
send -- "exampleuser"
expect -exact "exampleuser"
send -- "\r"
expect -exact "\r
Password: "
send -- "examplepasword\r"
expect -exact "\r
CCEMMT01-01>"
send -- "enable\r"
expect -exact "enable\r
Password: "
send -- "examplepasword\r"
expect -exact "\r
CCEMMT01-01#"
send -- "sh run "
expect -exact "\r
CCEMMT01-01#sh running-config "
send -- "\r"
expect -exact "\r
CCEMMT01-01#"
send -- "exit\r"
expect -exact "exit\r
example@host:~\$ "
send -- ""
expect eof
example@host:~$
답변1
귀하의 질문은 여기에 있다고 생각합니다.
expect -exact "\r
CCEMMT01-01#"
send -- "sh run "
expect -exact "\r
CCEMMT01-01#sh running-config "
send -- "\r"
전송 sh run
중이지만 CCEMMT01-01#sh running-config
인쇄가 예상되는 것처럼 보이지만 그렇지 않을 수도 있습니다.
노력하다:
expect -exact "\r
CCEMMT01-01#"
send -- "sh running-config \r"
명령 프롬프트를 기다린 다음 명령을 보냅니다 sh running-config
.