sasuser2006
Technical User
I'm trying to log into an ftp server to monitor for a file but when I do an ftp->ls it's not returning anything. Any help would be much appreciated.
The report looks like this...
I can't get the ftp->ls to list the files in the current directory. In case you're wondering the path returned is valid but for privacy purposes I've replace it. Any advice?
Code:
#!/usr/bin/perl
use Net::FTP;
my $now = localtime;
my $report_path = "/u01/home/ftp.log";
my $path = "path";
my $ftpdest = "host";
my $ftpuser = "user";
my $ftppass = "pass";
open (REPORT, ">$report_path");
print REPORT "It is now $now and the Outbound script has started!\n";
print REPORT "At $now connection to $ftpdest has started\n";
my $ftp;
$ftp = Net::FTP -> new($ftpdest, Debug => 0 ) || print REPORT "At $now connection to $ftpdest failed!\n";
print REPORT "At $now connection has been established\n";
$ftp->login($ftpuser,$ftppass) || print REPORT "At $now login attempt to $ftpdest failed!\n";
print REPORT "At $now login was successful!\n";
$ftp->cwd($path) || print REPORT " At $now change path to $path failed!\n";
$ftp->binary;
print REPORT "At $now the transfer method was changed to binary\n";
my $curr_dir = $ftp->pwd;
print REPORT "Current working directory is $curr_dir\n";
@all_files = $ftp->ls || print REPORT "Unable to list files";
foreach $file (@all_files){
$ftp-> get($file);
}
print REPORT "Downloaded $file!!!\n";
print REPORT "$file\n";
$ftp->close();
print REPORT "At $now the Outbound script completed!\n";
close REPORT;
exit;
The report looks like this...
Code:
It is now Thu Jul 20 18:30:25 2006 and the Outbound script has started!
At Thu Jul 20 18:30:25 2006 connection has started
At Thu Jul 20 18:30:25 2006 connection has been established
At Thu Jul 20 18:30:25 2006 login was successful!
At Thu Jul 20 18:30:25 2006 the transfer method was changed to binary
Current working directory is path
Downloaded !!!
At Thu Jul 20 18:30:25 2006 the Outbound script completed!
I can't get the ftp->ls to list the files in the current directory. In case you're wondering the path returned is valid but for privacy purposes I've replace it. Any advice?