Created
May 12, 2009 04:32
-
-
Save royw/110312 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
# quick hack to show all devices on the local lan | |
subnet = '192.168.80' | |
range = 1..254 | |
range.each do |i| | |
str = `host #{subnet}.#{i}` | |
unless str =~ /NXDOMAIN/ | |
if str =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)\..*\s(\S+)\.\s*$/ | |
ip = sprintf("%-15.15s", "#{$4}.#{$3}.#{$2}.#{$1}") | |
name = $5 | |
puts "#{ip} #{name}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment