can someone beta-test a little Speedport W 500 reconnect-script?

M

mrpink

Hi,
I wrote a little script for speedport and fritz.box router reconnecting.
For the Fritz.Box I can test it but I don't have a speedport so I was
wondering if one of you could test it?


require 'uri'
require 'rubygems'
require 'net/ping'
require 'net/http'




class Router

def initialize

@startIP = get_IP
puts get_IP #output

end

def get_IP

@url = URI.parse('http://www.wieistmeineip.de')
response = Net::HTTP.get_response(@url)
response.body.scan(/^Ihre IP-Adresse ist.+/) { |ipadresse| @IP =
ipadresse.sub(/^.+">/,'').sub(/<.+$/,'') }
get_IP=@IP

end

def check_new_ip

@check = false
@tryout = 0

while @check==false

if Net::pingExternal.new('www.google.com').ping

if @startIP != get_IP
puts get_IP #output
@check = true
else
@tryout++
my_router.reset(10) if tryout==5
end

end

end

end

def reset(waittime)

resetcommand
sleep(waittime)

end

end


class Fritz < Router

def resetcommand

@url='http://fritz.box/cgi-bin/webcm'
@passwort='1234567'
Net::HTTP.post_form(URI.parse(@url),
{'getpage' => '../html/de/menus/menu2.html',
'errorpage' => '../html/index.html',
'var:lang' => 'de',
'var:pagename' => 'home',
'var:menu' => 'home',
'login:command/password' => @passwort})
Net::HTTP.post_form(URI.parse(@url),
{'connection0:pppoe:settings/idle' => '5',
'connection0:pppoe:settings/mode' => 'on_demand'})
Net::HTTP.post_form(URI.parse(@url),
{'connection0:pppoe:settings/idle' => '0',
'connection0:pppoe:settings/mode' => 'lcp'})

end

end

class Speedport < Router

def resetcommand

@IP='192.168.0.1'
@passwort='1234567'
Net::HTTP.post_form(URI.parse(@IP+'/start.login'),{'P1' =>
@passwort})
Net::HTTP.get_response(@IP+'/pppctl.cmd?action=0')
Net::HTTP.post_form(URI.parse(@IP+'/start.login'),{'P1' =>
@passwort})
Net::HTTP.get_response(@IP+'/pppctl.cmd?action=1')

end

end



################################ actual code #############################

my_router = Speedport.new
my_router.reset(10)
my_router.check_new_ip
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top