Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/expect
- # Set up various other variables here ($user, $password)
- set timeout 15
- set password "Cisco_123"
- set f_read [open ./switches r]
- # itarate over the switches
- while {[gets $f_read device] != -1} {
- spawn telnet $device
- expect {
- timeout { continue }
- "Connection refused" {continue }
- "Username:" { continue }
- "Password:" { send "$password\r"; }
- "*>" { sleep 2 }
- }
- expect "*>"
- send "enable\r"
- expect "Password:"
- send "$password\r"
- expect "*#"
- send "copy tftp://192.168.200.199/reconf-auth.cfg running-config\r\r"
- expect "*#"
- sleep 5
- send "write\r"
- expect "*#"
- sleep 10
- send "logout\r"
- expect eof
- }
- # end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement