Last active
August 29, 2015 14:23
-
-
Save paralax/ebec2ae733b658c4f8da to your computer and use it in GitHub Desktop.
scala to get arp mappings
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
| import scala.sys.process._ | |
| val IP_PAT="(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})".r | |
| val MAC_PAT="([a-f0-9]{1,2}:[a-f0-9]{1,2}:[a-f0-9]{1,2}:[a-f0-9]{1,2}:[a-f0-9]{1,2}:[a-f0-9]{1,2})".r | |
| val res = "arp -na" !! | |
| (IP_PAT + "[^\\d]* .+ " + MAC_PAT).r.findAllMatchIn(res).map(_.subgroups).map(x => (x.head, x.last)).toMap // cala.collection.immutable.Map[String,String] = Map(192.168.0.102 -> 80:e6:50:25:xx:xx, ...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment