#!/usr/bin/expect -f set timeout 20 set TP_HOST [lindex $argv 0] set TP_IP [lindex $argv 1] set TP_USER [lindex $argv 2] set TP_PASS [lindex $argv 3] spawn ssh -o "StrictHostKeyChecking no" $TP_USER@$TP_IP 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