As Abigal-II has pointed out, not all FTP servers support transmitting file modification times, and the ones that do may not even transmit them in the same format. I think you have two options:
- Write a client-side script to parse the output of "ls -l" and grab the latest file
- Write a server-side script that symlinks the latest file to a known filename, such as "latest"
Here's some example code for the second way of doing things. Some example code is shown below:
#!/usr/bin/perl -w
use strict;
my $ftp_dir = '/pub/';
my @files = glob("$ftp_dir/*");
my ($latest_file,$modtime) = (0,0);
foreach my $file (@files) {
my $local_modtime = (stat($file))[9];
if ( $local_modtime > $modtime ) {
$latest_file = $file;
$modtime = $local_modtime;
}
}
# There's probably a better way to make symlinks
`ln -s $ftp_dir/$latest_file $ftp_dir/latest`;
The code is untested, but hopefully it can get the point across.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.