Debian 服务器“无法找到可加载对象”但“模块是最新的”
我正在尝试在使用 Net::Pcap 模块的 Debian 服务器上运行脚本。该脚本在所有机器上都可以正常工作,但这台服务器恰好是我需要它运行的唯一一台。
运行脚本时,我收到常见的“无法在@INC(路径..等..)中找到模块 Net::Pcap 的可加载对象”
但是,当我尝试使用 CPAN 安装时,我收到消息“Net ::Pcap 是最新的 (0.16)。”
我已从 @INC 中的所有文件夹中手动删除 Net::Pcap,并手动和通过 CPAN 重新安装它们。
有人知道我的问题是什么吗?
对于它的价值,这里是代码:
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);
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 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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您缺少本机库。尝试以 root 身份运行:
Maybe you are missing the native libs. Try to run as root:
以 jjmontes 的答案为基础:
strace
可能非常有帮助。例如,在这种情况下,您可以运行我今天遇到了类似的问题,XSLoader 找不到 Moose 的库(由于 NFS 文件句柄过时)。当我看到 strace 试图在许多路径中打开 Moose.so 但从未找到它时,我能够查出 Moose.so 是否丢失或不可读。然而,如果您不知道如何过滤 strace,它可能会产生很多噪音。
Building on jjmontes's answer:
strace
can be very helpful. For instance in this case you could have ranI 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.