Can someone beta-test a little Speedport W 500 reconnect-scr

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(/<.+$/,’’) }
[email protected]

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs