Last active
September 27, 2015 18:37
-
-
Save jatkins/1313715 to your computer and use it in GitHub Desktop.
Script for getting the MAC adreess of a large set of network computers.
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/ruby | |
ipconfig = `ifconfig` | |
interface = /(eth\d)/.match(ipconfig) | |
mac = /([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})/.match(ipconfig) | |
host = `hostname` | |
f = File.open("Macaddresses.txt", 'a') # This file should be on a share that all machines can access. | |
f << "#{host.chomp("\n")}" | |
f << " #{mac[0]}\n" | |
f.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment