more useful options PerlMonks

### Getting latest file from FTP server

 on Sep 19, 2002 at 14:21 UTC 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.

Replies are listed 'Best First'.
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];
[download]
you could do this cleaner with a regexp even.
Good Luck
Josh
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?

Create A New User
Node Status?
node history
Node Type: perlquestion [id://199182]
Approved by fireartist
help
Chatterbox?
 [Corion]: Do you want to launch a script and keep the command prompt/console window open? [Corion]: Do you want to wait for a key press before closing the window? [LanX]: I want the command line in the history [tye]: -Mouse [Corion]: Option a) would mean launching cmd.exe /k c:\path\to\ batchfile- launching-perl- script.cmd. Option b) would be to add pause as the last line of said batch file. [LanX]: First day after holidays ... and already stressed by the fact that colleagues changed stuff without communication ... apparently I'm the only one trying to fight entropy [Corion]: LanX: The command is always in the history if you typed it in before. If you didn't type the command into the command line, it will not be there. I think there is doskey which can stuff command lines into the history LanX damns the cult of CB ;-) LanX WTF WTF WTF [LanX]: please forget my last 3 posts

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2017-03-27 15:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Should Pluto Get Its Planethood Back?

Results (320 votes). Check out past polls.