Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Script to check for multiple files on FTP and print the one missing

by zork42 (Monk)
on Jul 01, 2013 at 05:07 UTC ( #1041737=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Script to check for multiple files on FTP and print the one missing
in thread Script to check for multiple files on FTP and print the one missing

Are you using Net::FTP?
Because that its documentation says that $ftp->ls($dir) returns a directory listing.
Assuming that to be the case, then something like this should work.

use strict; use warnings; my @files_to_check = ( 'abc.txt', 'xyz.txt', 'efg.txt' ); # list +of files to check my @directory_listing = $ftp->ls($dir); my %files_on_FTP_server; foreach my $file (@directory_listing) { # extra processing here? $files_on_FTP_server{$file} = 1; } foreach my $file (@files_to_check) { if ( ! $files_on_FTP_server{$file} ) { print "File $file is missin +g\n"; } }
However, as I do not know the format of @directory_listing, you might need some extra processing where indicated on line 12.
If @directory_listing contains a line of info for each file, you'd need a regexp to extract the file from each line, and you'd change line 10 from
foreach my $file (@directory_listing) to:
foreach my $line (@directory_listing)


UPDATE: s/Net::FTP/Net::FTP/ (ie linkified it)
s/that/its documentation/


Comment on Re^3: Script to check for multiple files on FTP and print the one missing
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1041737]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (17)
As of 2014-11-24 18:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (144 votes), past polls