I don’t find the error
this script should read the SNR margin of my adsl line from router and
write it on txt file…
like this but without window
but there is an error in the script
Can you help me?
require ‘open-uri’
log = File.new(“stats.log”, “a+”)
data = []
while true do
i = 0
open(
“http://192.168.0.1/stattbl.html",:http_basic_authentication=>["username”,
“password”] ).each do |page|
page.each do |html|
case html
when /<span.>.kbps</span>/
html.each { |line|
line.sub(/<span.>(.)kbps/) { data[i] = $1.strip }
}
i+=1
end
end
end
log.write “SNR: down(#{data[0]}) up(#{data[1]}) – #{Time.now.to_s}\n”
sleep 3
end
log.close
the error is
c:/ruby/lib/ruby/1.8/net/http.rb:2003:in each_response_header': wrong header line format (Net::HTTP BadResponse) from c:/ruby/lib/ruby/1.8/net/http.rb:1977:in read_new’
from c:/ruby/lib/ruby/1.8/net/http.rb:1044:in request' from c:/ruby/lib/ruby/1.8/open-uri.rb:261:in open_http’
from c:/ruby/lib/ruby/1.8/net/http.rb:543:in start' from c:/ruby/lib/ruby/1.8/open-uri.rb:245:in open_http’
from c:/ruby/lib/ruby/1.8/open-uri.rb:629:in buffer_open' from c:/ruby/lib/ruby/1.8/open-uri.rb:167:in open_loop’
from c:/ruby/lib/ruby/1.8/open-uri.rb:165:in open_loop' from c:/ruby/lib/ruby/1.8/open-uri.rb:135:in open_uri’
from c:/ruby/lib/ruby/1.8/open-uri.rb:531:in open' from c:/ruby/lib/ruby/1.8/open-uri.rb:86:in open’
from reader.rb:8
We don’t know what you want. Almost everything can be configured by
simply pointing your browser to routerlogin.net and working from there.
Neither a man nor a crowd nor a nation can be trusted to act humanely
or to think sanely under the influence of a great fear.
-Bertrand Russell, philosopher, mathematician, author, Nobel laureate
(1872-1970)
first of all thanks for the answer
then
We don’t know what you want.
sorry, maybe it’s my fault
I want that script run on windows by ruby and made a file with this
line (like example) on it:
SNR: down(23.6 db), up(8.0 db) – sab ago 5 15:53:51 CEST 2006
SNR: down(23.6 db), up(8.0 db) – sab ago 5 15:53:57 CEST 2006
SNR: down(23.6 db), up(8.0 db) – sab ago 5 15:54:02 CEST 2006
SNR: down(23.6 db), up(8.0 db) – sab ago 5 15:54:08 CEST 2006
SNR: down(23.4 db), up(7.5 db) – sab ago 5 15:54:13 CEST 2006
but it gave me an error.I don’t find it!
Almost everything can be configured by
simply pointing your browser to routerlogin.net and working from there.
sorry but don’t understand
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.