Last active
December 12, 2015 06:38
-
-
Save okochang/4730588 to your computer and use it in GitHub Desktop.
rubyからpingを実行したときのメモ
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
# -*- coding: utf-8 -*- | |
require 'net/ping' | |
## Pingの宛て先を指定して下さい | |
addr = 'google.co.jp' | |
pinger = Net::Ping::External.new(addr) | |
## Pingが通るかどうかテストします | |
if pinger.ping? | |
puts 'reachable' | |
else | |
puts 'unreachable' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment