INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Jobs from Indeed

Backup Cisco in txt

Backup Cisco in txt

(OP)
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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close