Linux Telnet Script to Reboot Dlink 502T under linux

spynic

Adept
well this method of modem rebooting has been around in the windows environment,
of great use to mtnl NU users..
but i could hardly find any script for linux.. finally after lots of searching, i found some scripts, did some editing for Dlink502T and got it running under linux
here's how its done..

Requirements : expect
Code:
# yum install expect

create file telnet.exp
open and add this: (you may change the ip address and password if you need)
Code:
#!/usr/bin/expect -f

set timeout 5

# router user name
set name "admin"

# router password
set pass "password"

# router IP address
set routerip "192.168.1.1"
# start telnet
spawn telnet $routerip

# send username & password
expect "Login:"
send -- "$name\r"
expect "Password:"
send -- "$pass\r"
# execute command
expect "#"
send -- "reboot\r"
# exit
expect "#"
send -- "^D"

set permissions to run script:
Code:
# chmod +x telnet.exp

run script
Code:
$ ./telnet.exp
 
Back
Top