Created
December 10, 2019 08:42
-
-
Save jezman/e32ea494736370d50fd8015365dbecbf to your computer and use it in GitHub Desktop.
Dlink switch backup. 1210 and 1510 series.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect | |
#============== | |
# 1510 series = | |
#============== | |
set switch "DGS-1510-52" | |
set ip "switch_ip" | |
set tftp_host "remote_tftp_server" | |
set password "pass" | |
set command "copy running-config tftp: " | |
set prompt "Switch#" | |
spawn ssh admin@$ip | |
set timeout 3 | |
expect { | |
yes { send -- yes\r } | |
password: { send -- $password\r } | |
} | |
expect -exact $prompt | |
send "$command\r" | |
expect host | |
send "$tftp_host\r" | |
expect filename: | |
send "config-$switch-$ip.bin\r" | |
expect -exact $prompt | |
send logout\r | |
#============== | |
# 1210 series = | |
#============== | |
set switch "DGS-1210-10" | |
set ip "switch_ip" | |
set tftp_host "remote_tftp_server" | |
set password "pass" | |
set command "upload cfg_toTFTP $tftp_host config-$switch-$ip.bin" | |
set prompt "$switch>" | |
spawn ssh admin@$ip | |
set timeout 3 | |
expect { | |
yes { send -- yes\r } | |
password: { send -- $password\r } | |
} | |
expect -exact $prompt | |
send "$command\r" | |
expect -exact $prompt | |
send logout\r |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment