Davide B. wrote:
Hi Axel,
I work on Mac Os X Leopard. Ruby works allright, I have also a number of
rails websites running locally, no problems so far.
Could you help me with the proper “script” sintax; I am sure the
rationale beyond the mechanism is correct, but I ultimately need to
integrate this script in a rails application, so I need to have it
woking in a common .rb file. As I said, tried thisrequire ‘open-uri’
begin
open “www.does.not.exist.sdadasdas.com”, :proxy=>true
p “i’m ok” #<-- ok codes here
rescue => e
p “sorry can’t do”
p “error is: #{e}”
endSimple as it seems, it does not work, I always end up with “i’m ok”. I’m
sure it’s some stupid syntactic glitch…
Any suggestion?
Davide
I relealize that that this may not solve your problem.
This above script works fine on my Mac
renard$ ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-darwin9.4.0]
renard$ which ruby
/usr/local/bin/ruby
renard$
irb(main):001:0> require ‘open-uri’
=> true
irb(main):002:0> begin
irb(main):003:1* open “www.does.not.exist.sdadasdas.com”, :proxy=>true
irb(main):004:1> p “i’m ok” #<-- ok codes here
irb(main):005:1> rescue => e
irb(main):006:1> p “sorry can’t do”
irb(main):007:1> p “error is: #{e}”
irb(main):008:1> end
“sorry can’t do”
“error is: can’t convert Hash into String”
=> nil
irb(main):009:0>