View Single Post
  #4   (View Single Post)  
Old 26th April 2010
TerryP's Avatar
TerryP TerryP is offline
Arp Constable
 
Join Date: May 2008
Location: USofA
Posts: 1,547
Default

Not reliably but some ftp daemons may have the ability to. The 'ls' and 'dir' commands in the ftp client, are basically just commands that tells the client to ask the server for a directory listing; I'm not sure if the extra (usually ls -l style) information is required.


Here's a test that finds the last 4 files in a directory, *if* they were created in the present or previous month:

Code:
Terry@dixie$ ftp -a ftp.freebsd.org << END  | grep -E "`date -v -1m +%b`|`date +%b`" | tail -n 4 | sort                                                        
        cd pub/FreeBSD
        ls
        quit
END                    
-rw-r--r--    1 110      1002        51703 Apr 26 05:32 dir.sizes
-rw-r--r--    1 110      1002     25830058 Apr 26 05:07 ls-lR.gz
drwxrwxr-x    7 110      1002          512 Apr 05 18:37 snapshots
drwxrwxr-x   10 110      1002          512 Mar 14 09:29 ports
Terry@dixie$
The grep and sort commands should really be replaced by a filter script, that understands how to collate/sort the entries into the order of months, e.g. Jan before Feb, March before Apr, etc. My suggestion would be Perl or AWK.

There's probably a few Perl modules on CPAN that can, and virtually every script language that supports arrays could pull off the task. (I would probably use AWK and a hand written look up table, but I'm to busy to check CPAN right now)
__________________
My Journal

Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''.
Reply With Quote