diff options
author | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2015-09-18 11:51:28 +0100 |
---|---|---|
committer | Nathan Lasseter <Nathan Lasseter nathan@bytemark.co.uk> | 2015-09-18 11:51:28 +0100 |
commit | b0a14e013b318fa87714414b8ece95780527bddf (patch) | |
tree | a9427383ab6e38a4421c9c4313043f6dfcb8e90e /macto |
Initial commit
Diffstat (limited to 'macto')
-rwxr-xr-x | macto | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -0,0 +1,17 @@ +#!/usr/bin/env ruby + +TO = ARGV.shift.chomp.downcase +MAC = ARGV.shift.chomp.gsub(/[.:]/, '') +UPPER = ARGV.shift ? true : false + +if MAC.match(/[0-9a-fA-F]{12}/).nil? then + puts "Not a valid MAC" + exit 1 +end + +case TO + when 'cisco' + puts (UPPER ? MAC.upcase : MAC).scan(/[A-Fa-f0-9]{4}/).join('.') + when 'canonical' + puts (UPPER ? MAC.upcase : MAC).scan(/[A-Fa-f0-9]{2}/).join(':') +end |