Skip to content

Instantly share code, notes, and snippets.

@subashz
Last active October 10, 2017 07:04
Show Gist options
  • Save subashz/5b5937bddb21fe9cd410de237fd9c168 to your computer and use it in GitHub Desktop.
Save subashz/5b5937bddb21fe9cd410de237fd9c168 to your computer and use it in GitHub Desktop.
Bash Script to reboot the router through telnet
#!/usr/bin/expect
# run script by installing expect
# chmod +x rebootrouter
# ./rebootrouter 192.168.0.1 admin password
#script will timeout after 20 seconds.
set timeout 20
set host [lindex $argv 1]
set user [lindex $argv 2]
set password [lindex $argv 3]
set command "reboot"
spawn telnet $host
#The script expects login
expect "wl-router login:"
#The script sends the user variable
send "$user\r"
#The script expects Password
expect "Password:"
#The script sends the password variable
send "$password\r"
# send reboot command after that
send "$command\r"
#to interact the session
interact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment