Skip to content

Instantly share code, notes, and snippets.

@komasaru
Created December 8, 2013 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save komasaru/7852894 to your computer and use it in GitHub Desktop.
Save komasaru/7852894 to your computer and use it in GitHub Desktop.
Ruby scripts to search a vendor name from a MAC address.
require 'open-uri'
class SearchMac
URL_OUI = "http://standards.ieee.org/develop/regauth/oui/oui.txt"
def initialize
@arg = ARGV[0]
end
def exec_main
begin
open(URL_OUI) do |f|
f.each do |line|
if /\s*(.*?)\s*\(hex\)\t*(.*?)\n/ =~ line
puts "#{$1}: #{$2}" if @arg == $1
end
end
end
rescue => e
STDERR.puts "[ERROR][#{self.class.name}.exec_main] #{e}"
exit 1
end
end
end
SearchMac.new.exec_main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment