Skip to content

Instantly share code, notes, and snippets.

@jatkins
Last active September 27, 2015 18:37
Show Gist options
  • Save jatkins/1313715 to your computer and use it in GitHub Desktop.
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.
#!/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