Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
manage NET HTTP errors
Andrea Campagna
5/20/2008 11:06:00 AM
Hi to all,
i've done a ruby script that restart a VoIP network device. The code i s
below:
url = URI.parse('
http://192.168.0.111/dologi...
)
response=Net::HTTP.start(url.host, url.port) {|http|
req = Net::HTTP::Post.new(url.path)
req.set_form_data({'P2'=>'password', 'Login' => 'login', 'gnkey' =>
'0b82'}, '&')
res=http.request(req)
puts res
cookie=res.get_fields('Set-Cookie')
cookie=cookie.to_s.match(/SessionId=((.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.))/).to_s
req=Net::HTTP::Get.new('/rs.htm')
req.add_field('Cookie',cookie)
http.request(req)
}
case response
when Net::HTTPSuccess then status=1
when Net::HTTPClientError then status=2
when Net::HTTPServerError then status=2
when Net::HTTPUnknownResponse then status=2
end
I've problems to manage these errors:
when the device is not connected i get an (Errno::EHOSTUNREACH) or the
script seems freezed....
Any suggetion???
Thanks in advance
Andrea
--
Posted via
http://www.ruby-...
.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
manage NET HTTP errors
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password