Created
December 4, 2012 09:26
-
-
Save paulmars/4202156 to your computer and use it in GitHub Desktop.
Mac Addresses
This file contains hidden or 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
| 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