Net::PingExternal gives an errror

Hello there,

I’m having a problem with a tutorial to ping whatever.
I have snowleopard and both ruby’s both give the same error:

uninitialized constant Net::PingExternal (NameError)

here is the code i’m using:

require ‘rubygems’
require ‘net/ping’
if Net::PingExternal.new(‘localhost’).ping
puts ‘Localhost OK’
else
puts ‘Localhost NO respons’
end

i dont know what to do.
I cleaned en update macports
updated rubygems and rubygems1.9
reinstalled ruby 1.8.7 and ruby1.9

Some help woud be nice thx

On Sep 16, 2010, at 4:22 PM, Younes B. wrote:

require ‘net/ping’
if Net::PingExternal.new(‘localhost’).ping
puts ‘Localhost OK’
else
puts ‘Localhost NO respons’
end

gem i net-ping

require ‘rubygems’
require ‘net/ping’
o = Net::Ping::TCP.new ‘www.ccc.de’, 80
o.ping? # => true

All the best, Sandor
Szücs

On Sep 16, 8:22 am, Younes B. [email protected] wrote:

Hello there,

I’m having a problem with a tutorial to ping whatever.
I have snowleopard and both ruby’s both give the same error:

uninitialized constant Net::PingExternal (NameError)

Try Net::Ping::External

Regards,

Dan

thanks it works but its not correct i try them both:

if Net::Ping::TCP.new(‘loocaalhost’)
puts ‘OK’
else
puts ‘NO respons’
end

if Net::Ping::External.new(‘loccalhost’)
puts ‘OK’
else
puts ‘NO respons’
end

this is the output:
OK
OK
webwizartbe-iMac:balbaert younesbaghor$

2 times ok even when the localhost is spelled wrong.

someone know what the difference is between
Net::Ping::TCP.new(‘localhost’)
Net::Ping::External.new(‘localhost’)

thanks allot

You didn’t call the ping? method in your example. You just called the
constructor.

someone �know what the difference is between
Net::Ping::TCP.new(‘localhost’)
Net::Ping::External.new(‘localhost’)

The external ping uses your system’s ping command. The TCP ping tries
to connect to the host via a Ruby TCPSocket.

Regards,

Dan

thanks Dan
indeed i mist the methode stupid off me
thanks for the fast reply and the explanation

On Sep 16, 4:17 pm, Younes B. [email protected] wrote:

else
puts ‘NO respons’
end

this is the output:
OK
OK
webwizartbe-iMac:balbaert younesbaghor$

2 times ok even when the localhost is spelled wrong.

You didn’t call the ping? method in your example. You just called the
constructor.

someone know what the difference is between
Net::Ping::TCP.new(‘localhost’)
Net::Ping::External.new(‘localhost’)

The external ping uses your system’s ping command. The TCP ping tries
to connect to the host via a Ruby TCPSocket.

Regards,

Dan

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