ftp a file by date and name match

Bob bobx at linuxmail.org
Tue Jul 8 10:29:14 EDT 2003


I am trying to get the latest file from an ftp site that matches a
pattern and is the latest one. I have it in Perl and would like to see
the Python version for comparison.

Perl version:

# this matches the name only by looking at files
# that start with 8 numbers (i.e. 20021203)
foreach(@list) {
    if(m/\d{8}.*x86.exe/) {
        push(@match,$_)
    }
}

if(scalar(@match)) {
    my $file=$match[$#match];
    $ftp->binary();
    $ftp->get($file);
}
$ftp->quit;




More information about the Python-list mailing list