Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Getting latest file from FTP server

by Anonymous Monk
on Sep 19, 2002 at 14:21 UTC ( #199182=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

How do I get the latest file that was uploaded in a given directory on an FTP server using NET::FTP. The ls -lt command gives me the listing in opposite chronological order for Unix FTP server and NT FTP server. I also need to get the time of upload. Any help will be appreciated.

Comment on Getting latest file from FTP server
Re: Getting latest file from FTP server
by sch (Pilgrim) on Sep 19, 2002 at 14:23 UTC

    I haven't used the NET::FTP module, but thinking from a purely unix standpoint, would ls -lrt help?

Re: Getting latest file from FTP server
by krujos (Curate) on Sep 19, 2002 at 15:52 UTC
    You could use ls -lrt (which reverses the list by time updated). Something like
    $tmp = `ls -lrt`; @array = split /\n/,$tmp; print $array[@array-1];
    you could do this cleaner with a regexp even.
    Good Luck
    Josh

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-12-25 18:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (162 votes), past polls