#!/usr/bin/perl use File::Fetch; # for downloading things $cache = 'ouisearch'; $mac = ''; if($ARGV[0] =~/^[\dA-F]{2}([:\-]?[\dA-F]{2}){2}$/) { if(length($ARGV[0]) == 6) { $mac = substr($ARGV[0],0,2).'-'.substr($ARGV[0],2,2).'-'.substr($ARGV[0],4,2); } else { $mac = substr($ARGV[0],0,2).'-'.substr($ARGV[0],3,2).'-'.substr($ARGV[0],6,2); } } else {die 'First parameter should be beginning of MAC address!';} $ff = File::Fetch->new(uri => 'http://standards.ieee.org/cgi-bin/ouisearch?'.$mac); $where = $ff->fetch('to' => './') or die $ff->error; $status = 0; open (F, $cache) || die "Could not open ".$cache.": $!\n"; foreach $line () { if($status == 1) { if($line =~/<\/pre><\/p>/) { $status=2; break; } else { print $line; } } if($status == 0 && $line =~/^

[\dA-F]{2}-[\dA-F]{2}-[\dA-F]{2}<\/b>/) { $status = 1; }
}
close F;

system('rm '.$cache);
if($status<1) { die "Didn't find information for MAC address beginning ".$mac; }