| 123456789101112131415161718192021222324252627282930313233 | #!/usr/bin/expect -fset timeout 20set TP_HOST [lindex $argv 0]set TP_IP [lindex $argv 1]set TP_USER [lindex $argv 2]set TP_PASS [lindex $argv 3]spawn telnet $TP_IPexpect "*ser: "send "$TP_USER\r"expect "*assword: "send "$TP_PASS\r"expect "*>"send "enable\r"expect "*#"send "enable-admin\r"expect "*#"send "copy startup-config tftp ip-address 172.30.1.221 filename $TP_HOST\r"expect "*#"send "exit\r"expect "*>"send "exit\r"exit
 |