Skip to content

Instantly share code, notes, and snippets.

@paulmars
Created December 4, 2012 09:26
Show Gist options
  • Select an option

  • Save paulmars/4202156 to your computer and use it in GitHub Desktop.

Select an option

Save paulmars/4202156 to your computer and use it in GitHub Desktop.
Mac Addresses
require 'rubygems'
require 'awesome_print'
pings = `ping -c4 10.0.1.255`.split("\n")
valid = pings.select{|p| p.match("64 bytes") }
ips = valid.map{|v| v.split(":").first.split(" ").last }.uniq
arps = ips.map{|ip| `arp #{ip} ` }
valid_arps = arps.select{|a| a.match("at") }
macs = valid_arps.map{|a| a.split(/on|at/)[1].strip }
ap macs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment