对CPAN模块的递归依赖,如何?

时间:2012-08-15 04:01:57

标签: perl cpan

如何在perl中安装模块Nmap :: Scanner与cl的所有依赖关系?我做了,cpan Nmap :: Scanner。但是,需要模块的其他依赖项。

此代码。

#!/bash/perl

  use Nmap::Scanner;
  my $scan = Nmap::Scanner->new();

  $scan->add_target('localhost');
  $scan->add_target('host.i.administer');
  $scan->add_scan_port('1-1024');
  $scan->add_scan_port('31337');
  $scan->tcp_syn_scan();
  $scan->noping();

  my $results = $scan->scan();

  my $hosts = $results->gethostlist();

  while (my $host = $hosts->get_next()) {

      print "On " . $host->hostname() . ": \n";

      my $ports = $host->get_port_list();

      while (my $port = $ports->get_next()) {
          print join(' ',
              'Port',
              $port->service() . '/' . $port->portid(),
              'is in state',
              $port->state(),
              "\n"
          );
      }

  }

我做了,但是在perl中运行脚本时,在控制台中显示了这个。

Can't locate XML/SAX/Exception.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl` /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at /usr/local/share/perl5/XML/SAX/ParserFactory.pm line 12.
BEGIN failed--compilation aborted at /usr/local/share/perl5/XML/SAX/ParserFactory.pm line 12.
Compilation failed in require at /usr/local/share/perl5/Nmap/Scanner/Backend/XML.pm line 8.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Nmap/Scanner/Backend/XML.pm line 8.
Compilation failed in require at /usr/local/share/perl5/Nmap/Scanner/Scanner.pm line 4.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Nmap/Scanner/Scanner.pm line 4.
Compilation failed in require at /usr/local/share/perl5/Nmap/Scanner.pm line 10.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Nmap/Scanner.pm line 10.
Compilation failed in require at e1-insecure.pl line 3.
BEGIN failed--compilation aborted at e1-insecure.pl line 3.

1 个答案:

答案 0 :(得分:3)

cpan自动解决依赖关系。要安装,请执行以下命令:

cpan Nmap::Scanner

CPAN模块的替代安装程序是cpanminus。使用cpanm

cpanm Nmap::Scanner