1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
   |  
#!/opt/csw/bin/perl
use strict;
use Net::FTP;
 
my $ftpserver="XXX.XXX.XXX.XXX";
my $ftpuser="XXXXXXX";
my $ftppsswd='XXXXXXX';
my $ftpdirectory="/XXX";
 
print("Connecting to ftp server ...\n");
my $ftp = Net::FTP->new($ftpserver,
   Debug => 0, Passive =>1, Timeout=>10 ) or die("Cannot connect to some.host.name: $@");
   print("Connected to server ...\n");
   print("Login to ftp server ...\n");
$ftp->login($ftpuser,$ftppsswd) or die "Cannot login ", $ftp->message;
   print("Logged to ftp server ...\n");
   print("Changing directory ...\n");
$ftp->cwd($ftpdirectory) or die "Cannot change working directory ", $ftp->message;
print("Listing files ...\n");
my @list=$ftp->ls() or die "Cannot listing files in directory ! ",$ftp->message;
print("Closing connection...");
 
$ftp->quit();
print("Connection closed ...\n");
for (@list)
{
       print($_."\n");
 } | 
Partager