Skip to content

Instantly share code, notes, and snippets.

@jerodsanto
Created April 9, 2009 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerodsanto/92714 to your computer and use it in GitHub Desktop.
Save jerodsanto/92714 to your computer and use it in GitHub Desktop.
require 'ping'
unless ARGV.first =~ /\d+\.\d+\.\d+\.\d+/
puts "Bad Network address: #{ARGV.first}"
exit 1
end
$stdout = File.open(ARGV.last,"w") if ARGV.size == 2
class_c = ARGV.first.gsub(/\d+$/,"")
255.times do |i|
ip_address = class_c + i.to_s
if Ping.pingecho(ip_address, 1)
$stdout.puts "#{ip_address} is up"
$stdout.flush
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment