Kitz Forum

Broadband Related => Router Monitoring Software => Topic started by: broadstairs on December 30, 2012, 02:24:49 PM

Title: Another expect script to force a re-sync without re-booting the router
Post by: broadstairs on December 30, 2012, 02:24:49 PM
I knocked up this expect script in order to be able to force the HG612 to re-sync without doing a re-boot, as there is no re-sync option currently that I've found in the gui for this router. Saves me having to remember the syntax! Same thing applies as for the previous script, on Windows it may work if you install the Expect package, Linux users may find it is a default package on stuff like Fedora (but apparently not on Debian). Save as  someting like HG612-resync.expect (and set execute permssion on Linux)

Code: [Select]
#!/usr/bin/expect -f
# Expect script to supply root/admin password for remote ssh server
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# ----------------------------------------------------------------------
# This script will force a re-sync without the need for a re-boot of the router.
# It does this by issuing the xdslcmd to take down and then bring up the connection.
#
# set Variables
set command [lrange $argv 0 0]
set timeout -1   
#
stty echo
send_user -- "Enter IP address of router: "
expect_user -re "(.*)\n"
send_user "\n"
stty echo
set ipadd $expect_out(1,string)
#
spawn telnet $ipadd
match_max 100000

expect "*Login:"
send -- "admin\r"
expect "*?assword:"
send -- "admin\r"
expect "ATP>"
send -- "sh\r"
expect "# "
send -- "\r"
expect "*# "
send -- "xdslcmd connection --down\r"
expect "*# "
sleep 2
send -- "xdslcmd connection --up\r"
expect "*# "
send -- "exit\r"
expect "ATP>"
send -- "exit\r"
expect eof

Stuart
Title: Re: Another expect script to force a re-sync without re-booting the router
Post by: roseway on December 30, 2012, 02:41:35 PM
Another useful one. I don't want to re-sync right now, but I'll give it a try soon.