linebacker has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/local/bin/perl -w use Net::FTP; $host = 'www.ftp.com'; $user = 'anonymous'; $pass = 'updatepuller@ftp.com'; $remote_dir = '/path/to/remote/filesendinginmmddx86.exe'; $oldfilename = `ls current-sig`; chomp $oldfilename; $destination_dir= "current-sig"; $ftp = Net::FTP->new($host, Debug => 1); $ftp->login($user,$pass); my @listing = $ftp->ls("$remote_dir"); for (@listing) { if ( /x86\.exe/i ) { open(FH, ">> myfile.txt") || die "Can't open $file for write: $!"; print FH "$_\n" } } close FH; #$ftp->get("$remote_dir/$filename","$destination_dir/$filename"); $ftp->pasv(); $ftp->quit; open( OUT, "> myfile.new") or die "$!"; open( NFH, "myfile.txt") or die( "Cannot open file : $!" ) ; while (<NFH>) { #($month,$day) =~ /(\d\d)(\d\d)x86\.exe/ # m/([0-9][0-9][0-9][0-9])/; print( OUT "$1\n" ); } #close NFH or die( "Cannot close file: $!" ); #close OUT or die( "Cannot close file: $!" ); #open( NEWTIMES, "<myfile.new") or die "$!"; #while ( <NEWTIMES> ) { # m/([0-9][0-9])/; # @month = ("$1\n") ; # } #while ( <NEWTIMES> ) { # s/([0-9][0-9])//; # @day = ("$1\n") ; # } #close NEWTIMES or die( "Cannot close file: $!" );
Edit by dws to clean up title
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing file dates then downloading newer files through ftp
by grinder (Bishop) on Jun 25, 2002 at 22:22 UTC | |
|
Re: Comparing file dates then downloading newer files through ftp
by kvale (Monsignor) on Jun 25, 2002 at 22:24 UTC |