#!/usr/bin/expect -f set timeout 20 # router user name set name "root" # router password set pass "burayasifregelecek" # router IP address set routerip "192.168.1.1" # Read command as arg to this script set routercmd [lindex $argv 0] # start telnet spawn telnet $routerip # send username & password expect "login:" send -- "$name\r" expect "Password:" send -- "$pass\r" expect "cli>" send -- "enable\r" expect "Password:" send -- "Admin\r" expect "cli#" send -- "reboot\r" expect "Are you sure" send -- "y\r" # get out of ISP's Stupid menu program, go to shell #expect " -> " #send -- "sh\r" # execute command #expect "# " #send -- "$routercmd\r" # exit send -- "^D"