Резервное копирование Cisco с помощью expect

Я хотел сделать резервную копию запущенного конфига, но не получилось, как я хотел, как мне сбросить данные в 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:~$ 
0
13.09.2016, 19:31
0 ответов

Теги

Похожие вопросы