Skip to content

Instantly share code, notes, and snippets.

@doyle
Created August 30, 2016 17:41
Show Gist options
  • Save doyle/eb13b16fc355dc5653f24be389b6bf1f to your computer and use it in GitHub Desktop.
Save doyle/eb13b16fc355dc5653f24be389b6bf1f to your computer and use it in GitHub Desktop.
Searches all of the ip addresses in a range and prints out a message if a machine is found
(0..255).each do |i|
ip = "192.168.1.#{i}"
result = `ping -c 1 -W 5 #{ip}`
if result.match(/1 packets received/)
puts "something on #{ip}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment