Monday, March 24, 2014

Ping script with ruby

172:rp young$ cat ping.rb 
require 'rubygems'
require 'net/ping'
if Net::Ping::External.new(ARGV[0]).ping
   puts "Pong!"
else
   puts "No response"

end

172:rp young$ ruby ping.rb www.google.com
Pong!
172:rp young$ 

No comments:

Post a Comment