Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Backup Cisco in txt

Status
Not open for further replies.

ginesgb

Technical User
Sep 15, 2016
3
ES
I have corrected the code line and now I just need to dump information to a data file text. I set the output option to open "ASR $ now.txt" "w" but I'm still getting an error. What information do I need to work?

#!/usr/bin/expect -f

set timeout -1
spawn $env(SHELL)
match_max 100000
expect -exact "use@home:~\$ "
send -- "telnet xxx.xxx.xxx.xxx"
expect -exact "telnet xxx.xxx.xxx.xxx"
send -- "\r"
expect -exact "\r
Trying xxx.xxx.xxx.xxx...\r
Connected to xxx.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 -- "examplepassword\r"
expect -exact "\r
ROUTERCISCO>"
send -- "enable\r"
expect -exact "enable\r
Password: "
send -- "examplepassword\r"
expect -exact "\r
ROUTERCISCO#"
send -- "terminal length 0"
expect -exact "terminal length 0"
send -- "\r"
expect -exact "\r
ROUTERCISCO#"
send -- "show running-config"
expect -exact "show running-config"
set output [open "/home/redip/new.txt" "a+"]
sleep 2
set outcome $expect_out(buffer)
puts $output $outcome
incr i
close $output
send -- "\r"
expect -exact "\r
!\r
!\r
!\r
!\r
end\r
\r
ROUTERCISCO#"
send -- "exit\r"
expect -exact "exit\r
Connection closed by foreign host.\r
use@home:~\$ "
send -- ""
expect eof
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top