开发者

Debian server "Can't locate loadable object" yet "Module is up to date"

I am trying to run a script on a Debian server that uses module Net::Pcap. The script works fine on all machines but this server, which happens to be the only one I NEED it to run on.

Upon running the script, I get the开发者_JAVA百科 common "Can't locate loadable object for module Net::Pcap in @INC (path.. etc..)"

However, when I try to install using CPAN, I receive the message "Net::Pcap is up to date (0.16)."

I have manually removed Net::Pcap from all folders in @INC and reinstalled them both manually and through CPAN.

Anyone have a clue what my problem is?

For what it's worth, here is the code:

    use Net::Pcap;
    use NetPacket::TCP;
    use NetPacket::IP;
    use NetPacket::Ethernet;
    use Net::PcapUtils;

    open (TXT, ">", "data.txt");
    Net::PcapUtils::loop(\&process_packet,SNAPLEN => 65536,PROMISC => 1, );

    sub process_packet {
      my($user_data, $header, $packet) = @_;
      my $tcp_obj = NetPacket::TCP->decode($packet);
      my $ip_obj = NetPacket::IP->decode($packet);
      my $len = length $packet;
      my $i=0;
      print TXT "From: "."$ip_obj->{src_ip}".":"."$tcp_obj->{src_port}\n";
      print TXT "To: "."$ip_obj->{dest_ip}".":"."$tcp_obj->{dest_port}\n";
      do {    
        my $lg = substr $packet, $i, 16;
        printf TXT "%.8X : ", $i;
        $i+=16;
        print TXT unpack ('H2'x16, $lg), '  'x(16-length $lg);
        $lg =~ s/[\x00-\x1F\xFF]/./g;
        print TXT " $lg\n";
        } until $i>=$len;
        print TXT "\n";
      }
   close (TXT);


Maybe you are missing the native libs. Try to run as root:

apt-get install libnet-pcap-perl


Building on jjmontes's answer:

strace can be very helpful. For instance in this case you could have ran

strace perl -e 'use Net::Pcap'

I had a similar issue today where XSLoader couldn't find a library for Moose (due to a stale NFS file handle). When I saw strace trying to open Moose.so in many paths and never finding it I was able to track down that Moose.so was either missing or not readable. However, strace can be a lot of noise if you don't know how to filter through it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜