简体   繁体   English

无法在Perl中使用Net :: SFTP模块

[英]Not able to use Net::SFTP module in Perl

I am using perl, v5.10.1 on my Linux Ubuntu machine. 我在我的Linux Ubuntu机器上使用perl,v5.10.1。 I tried to install Net::SFTP module through cpan prompt but its giving the below errors for past 2 days. 我试图通过cpan提示安装Net::SFTP模块,但它在过去2天内给出了以下错误。

warning: 警告:

Warning: no success downloading
'/root/.cpan/sources/authors/01mailrc.txt.gz.tmp19821'. Giving up on
it. at /usr/share/perl5/CPAN/Index.pm line 225

error: 错误:

Connecting to www.perl.org|207.171.7.51|:80... failed: Connection
timed out.

Connecting to www.perl.org|207.171.7.41|:80... failed: Connection
timed out.

Then I installed it by tar file method through CPAN site. 然后我通过CPAN站点通过tar文件方法安装它。 now when I run the below sample script its throwing me the error. 现在,当我运行下面的示例脚本时,它会向我抛出错误。

script: 脚本:

use Net::SFTP;

my $host = "169.144.106.231";
my %args = ( 
        user => "root",
        password => "******" );

my $sftp = Net::SFTP->new($host, %args);

Error: 错误:

Can't locate Net/SSH/Perl/Buffer.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/share/perl5/Net/SFTP/Buffer.pm line 6.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Net/SFTP/Buffer.pm line 6.
Compilation failed in require at /usr/local/share/perl5/Net/SFTP/Attributes.pm line 7.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Net/SFTP/Attributes.pm line 7.
Compilation failed in require at /usr/local/share/perl5/Net/SFTP.pm line 8.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Net/SFTP.pm line 8.
Compilation failed in require at ankur_sftp.pl line 6.
BEGIN failed--compilation aborted at ankur_sftp.pl line 6.

I don't have Net/SSH/Perl/Buffer.pm installed and few modules like Buffer.pm are residing at some other path. 我没有安装Net/SSH/Perl/Buffer.pm而且很少有像Buffer.pm这样的模块驻留在其他路径上。

/root/Net-SFTP-0.10/blib/lib/Net/SFTP/Buffer.pm
/root/Net-SFTP-0.10/lib/Net/SFTP/Buffer.pm

My @INC contains 我的@INC包含

/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
usr/lib64/perl5
/usr/share/perl5

Can anyone please help here? 有人可以帮忙吗? Why is cpan prompt method is throwing that error? 为什么cpan prompt方法抛出了这个错误? Next for tar file method if there is module dependency issue then how to resolve it using CPAN tar file method? 接下来对于tar文件方法,如果存在模块依赖问题,那么如何使用CPAN tar文件方法解决它? Also how to install the modules on the correct path because I don't want to add all the required module's paths in @INC path in the beginning of my script. 另外,如何在正确的路径上安装模块,因为我不想在脚本开头的@INC路径中添加所有必需的模块路径。 I am a root user here. 我是root用户。

Can't locate Net/SSH/Perl/Buffer.pm 找不到Net / SSH / Perl / Buffer.pm

That means the Net::SSH::Perl::Buffer module is missing. 这意味着缺少Net::SSH::Perl::Buffer模块。 You need to install it. 你需要安装它。

Net/SFTP/Buffer.pm is not same as Net::SSH::Perl::Buffer. Net / SFTP / Buffer.pm与Net :: SSH :: Perl :: Buffer不同。

You're facing the dependency issue, either you will have to go to CPAN and download tar file and install module, and you will have to do this for each missing module. 您将面临依赖性问题,要么您必须转到CPAN并下载tar文件并安装模块,您必须为每个缺少的模块执行此操作。 I would suggest you to try CPAN client, or App::cpanminus so that the dependencies can be installed automatically. 我建议您尝试CPAN客户端或App :: cpanminus,以便可以自动安装依赖项。

For that see this: Installing perl dependency automatically in perl 为此,请参阅: 在perl中自动安装perl依赖项

I don't want to add all the required module's paths in @INC path in the beginning of my script 我不想在脚本开头的@INC路径中添加所有必需模块的路径

Then make sure the @INC contains the path where your modules are getting installed. 然后确保@INC包含安装模块的路径。 You can tell it by 你可以告诉它

export PERL5LIB=/home/foobar/code (For Linux) (Add this to ~/.bashrc to make it always available when you log-in.) export PERL5LIB=/home/foobar/code (对于Linux)(将其添加到~/.bashrc以使其在您登录时始终可用。)

set PERL5LIB = c:\\path\\to\\dir (For Windows) set PERL5LIB = c:\\path\\to\\dir (适用于Windows)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM