Vict0rC has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I am using linux app NetDB, with some perl modules. One of them is capable of translating mac addresses using other perl module NET:MAC:Vendors.

And here comes my problem...

After I installed NET:MAC:Vendors module I am able to use it directly from command line (/Vendord.pm <MAC>) and translate MACs right way using online query to database as it is described here http://search.cpan.org/~bdfoy/Net-MAC-Vendor-1.25/lib/Net/MAC/Vendor.pm

BUT!

When I want to use it as it is described in NetDB documentation, it returns error and MACs are not translated. Error is simple - it cant load data from local txt db using load_cache( file://path/to/file.txt) function.

ERROR - Net::Mac::Vendor cache source [file://opt/netdb/data/oui.txt] does not exist at /usr/lib/perl5/NetDB.pm line 2468

Local txt file is 10000% correct, with all needed permissions. Checked it hundred times.

So I tried to create simple pl script, just to find, why it is not working and If I can reproduce the error. What a surprise, simple pl script, just three lines of code to load cache from txt file - and error is the same :(

#!/usr/bin/perl use strict; use Net::MAC::Vendor; Net::MAC::Vendor::load_cache("file://opt/netdb/netmacvendor/oui.txt");

ERROR - Net::Mac::Vendor cache source [file://opt/netdb/netmacvendor/oui.txt does not exist at ./net-mac-vendor-test.pl line 4.

I am newbie to perl so I dont know what can be wrong... Thanks anyone who can help me with it...

VictorC

P.S. Here is more about my problem in NetDB forum https://sourceforge.net/p/netdbtracking/discussion/939989/thread/15661611

Replies are listed 'Best First'.
Re: NetDB - Problem with perl module NET:MAC:Vendors
by Corion (Patriarch) on Oct 12, 2015 at 16:52 UTC

    Maybe try the following first:

    my $filename = '/opt/netdb/netmacvendor/oui.txt'; open my $fh, '<', $filename or die "Couldn't read $filename: $!";

    Also, file:// URIs are somewhat underspecified. Sometimes I've experienced needing three slashes for the path:

    file:///opt/netdb/netmacvendor/oui.txt

    ... and sometimes only one:

    file:/opt/netdb/netmacvendor/oui.txt

    If you have URI::file installed (likely), you can test what you really need:

    use URI::file; print URI::file->new('/opt/netdb/netmacvendor/oui.txt');

      Hello and thanks for reply, I tried all you adviced but nothing helped yet...

      my $filename = '/opt/netdb/netmacvendor/oui.txt'; open my $fh, '<', $filename or die "Couldn't read $filename: $!";

      This outputs nothing :(

      use URI::file; print URI::file->new('/opt/netdb/netmacvendor/oui.txt');

      And this outputs three slashes: file:///opt/netdb/netmacvendor/oui.txt

      So I put file:///opt/netdb/netmacvendor/oui.txt in the code, bud error persists :(

      #!/usr/bin/perl use strict; use Net::MAC::Vendor; use URI::file; print URI::file->new('/opt/netdb/netmacvendor/oui.txt'); Net::MAC::Vendor::load_cache("file:///opt/netdb/netmacvendor/oui.txt") +; my $filename = '/opt/netdb/netmacvendor/oui.txt'; open my $fh, '<', $filename or die "Couldn't read $filename: $!";

      This outputs same error: Net::Mac::Vendor cache source [file:///opt/netdb/netmacvendor/oui.txt] does not exist at ./net-mac-vendor-test.pl line 7.

        Meh - looking ath the source code of Net::MAC::Vendors, it seems that its documentation is simply wrong:

        ... sub load_cache { my( $source, $dest ) = @_; my $data = do {; if( defined $source ) { unless( -e $source ) { carp "Net::Mac::Vendor cache source [$source] does not + exist"; return; } do { local( @ARGV, $/ ) = $source; <> } } else { __PACKAGE__->ua->get( oui_url() )->res->body; } }; ...

        Try simply passing a plain filename to it:

        Net::MAC::Vendor::load_cache("/opt/netdb/netmacvendor/oui.txt");

        Also, opening a bug report here might help :-)