Skip to content

Instantly share code, notes, and snippets.

@royw
Created May 12, 2009 04:32
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 royw/110312 to your computer and use it in GitHub Desktop.
Save royw/110312 to your computer and use it in GitHub Desktop.
#!/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