
cuboidgraphix
User
Jul 19, 2010, 2:49 PM
Post #1 of 5
(5996 views)
|
Reopened: FTP to multiple directories and get files.
|
Can't Post
|
|
Hello guys, Sorry to bother you all again, but 3 days ago we had a major system crash and now my script it not working properly. I've tried checking and checking and I can't figure it out. So I have to turn to the professionals. Below I have the script with my remarks. Please NOTE that the script runs all the way through, but no files are being pulled via FTP. I would like to verify each step to see where exactly the error is. At this point I get an error ... "Transfer in progress... request aborted" or something like that. I feel as though the problem lies at the my @File line.
#!/usr/bin/perl use strict; use warnings; use Net::FTP; use POSIX qw/strftime/; my $Yday = strftime("R%y%m%d", localtime(time - 86400)); chdir "/home/AMA"; my @myDIR =('D010AMAB', 'D000AMAA', 'D010AMA9', 'D000AMA8', 'D010AMA5', 'D000AMA6', 'D010AMA7', 'D000AMA4', 'D010AMA3', 'D000AMA2', 'D010AMA1', 'D000AMA0' ); my $ftp = Net::FTP->new("HOST", Debug => 1) or die "Failed to connect to FTP server "; print $ftp->message(), "\n"; $ftp->login("USER",'PASS') or die "Failed to login to FTP server "; print $ftp->message(), "\n"; foreach my $DIR(@myDIR){ print "changing cwd to $DIR\n\n"; $ftp->cwd("/$DIR") or warn "Failed to cd to /$DIR ", print $ftp->message() and next; print $ftp->message(); $ftp->ascii or warn "Unable to switch to ascii mode "; my @file = grep { /^([^.].*)?$Yday/ } $ftp->ls(); // I would like to verify by printing the list of files in the volume. $ftp->binary or warn "Unable to switch to binary mode "; foreach my $file(@file){ print "retriving file '$file'\n"; // There is no print out here. Before it would say which file it is transfering. Nothing now. $ftp->get($file) or warn "Failed to retrieve '$file' ", print $ftp->message() and next; print $ftp->message(); } }
|