- #!/usr/bin/expect -f
- set ip [lindex $argv 0]
- set pass [lindex $argv 1]
- set enable [lindex $argv 2]
- set tftpserver [lindex $argv 3]
- set port [lindex $argv 4]
- set force_conservative 0 ;# set to 1 to force conservative mode even if
- ;# script wasn't run conservatively originally
- if {$force_conservative} {
- set send_slow {1 .1}
- proc send {ignore arg} {
- sleep .1
- exp_send -s -- $arg
- }
- }
- set timeout -1
- spawn $env(SHELL)
- match_max 100000
- send -- "telnet $ip $port\r"
- expect "Password:"
- send -- "$pass\r"
- expect ">"
- send -- "enable\r"
- expect "Password:"
- send -- "$enable\r"
- expect "#"
- send -- "write mem\r"
- expect "#"
- send -- "write net\r"
- expect "Address or name of remote host"
- send -- "$tftpserver\r"
- expect "?"
- send -- "\r"
- expect "confirm"
- send -- "\r"
- expect "OK"
- send -- "exit\r"
Raw Paste