基于Linux系统环境下,用Perl程序去远程服务器上用Net::FTP模块去打印文件列表

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_28847617/article/details/80279614
#!/usr/bin/perl

package file_ftp;

use strict;
use warnings;
use Net::FTP;


unshift(@INC,"$ENV{work_path}");

my $ip="***";

my $username="***";

my $password="******";

my $cd="/app/tmn/ftpeoms";


my $lcd="/app/***/***/***/***/perl_learn";

my $file_mode="*.sh";

my $file_list="list.txt";

open (out_list,">> $lcd/$file_list") or die "not touch the new file $!";

my $ftp=Net::FTP->new($ip,Debug=>1,Timeout=>30);


$ftp->login($username,$password);

$ftp->binary();

$ftp->cwd($cd);

my @file_list=$ftp->ls($file_mode);

foreach (@file_list)
{
print out_list $_."\n";
}
my $file_num=@file_list;   
print "文件总数:$file_num\n";
$ftp->quit();
1;

猜你喜欢

转载自blog.csdn.net/qq_28847617/article/details/80279614