Sajjad Po wrote:
> /usr/lib/ruby/1.8/timeout.rb:60:in `timeout': execution expired  from
> /usr/lib/ruby/1.8/ping.rb:46:in `pingecho'
>   from a.rb:27
>   from a.rb:26:in `each'
>   from a.rb:26

What if you just run it from irb? I get the following under Linux:

$ irb --simple-prompt
>> require 'ping'
=> true
>> Ping.pingecho('1.1.1.1', 2, 80)
=> false
>> RUBY_VERSION
=> "1.8.7"
>> RUBY_PATCHLEVEL
=> 174

Looking at the source code for ping.rb around line 46:

    begin
      timeout(timeout) do
        s = TCPSocket.new(host, service)
        s.close
      end
    rescue Errno::ECONNREFUSED
      return true
    rescue Timeout::Error, StandardError
      return false
    end

I don't understand why the exception isn't being caught. You could try 
adding:

    rescue Exception => e
      $stderr.puts "Actual exception: #{e.class.inspect}"

just before the 'end', see if that shows anything.

Incidentally, if you're trying to ping lots of hosts, 'multiping' may be 
a better tool. It can ping them all in parallel, and you can run it from 
ruby using IO.popen or %x{..} to collect the results.
-- 
Posted via http://www.ruby-forum.com/.