Created
June 15, 2010 20:06
-
-
Save jerodsanto/439650 to your computer and use it in GitHub Desktop.
A poor man's replacement for Ruby's Ping.pingecho method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ping.pingecho uses TCP echo requests, which sucks when you really want | |
# to know if the machine is pingable, ie - it answers ICMP requests | |
# Here's a poor man's replacement for use in a pinch: | |
def pingable?(host, timeout=5) | |
system "ping -c 1 -t #{timeout} #{host} >/dev/null" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey! I'm speaking from the future. 8 years after you wrote this.
You can still reimplement that old code source https://ruby-doc.org/stdlib-1.8.7/libdoc/ping/rdoc/Ping.html