cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Directory Listing

From: Alessandro Vesely <vesely_at_tana.it>
Date: Fri, 04 Jan 2008 17:07:34 +0100

Matt Wills wrote:
> Using the command
>
> curl ftp://USER:PASSWORD@DOMAIN/PATH
>
> I receive a directory listing in this format:
>
> -rw-r--r-- 1 domain psacln 72528 Dec 16 09:47 albany.jpg
>
> Note that the date is just the month and day.

That's the usual "ls -l" output, see e.g.
http://www.freebsd.org/cgi/man.cgi?query=ls

Note that the year is written instead of hour:minute in case of files
older than six months.

> If I look at the same directory in an FTP client, I see the COMPLETE
> date of Dec 16 2007.

Are you sure? Is your FTP client interpreting that string or does it
issue a different command? You can tell the difference if the client
is unable to display the hour:minute information of old files. The
FEAT command may also be helpful, if supported.

> Is there a reason curl doesn't return the year, and is there a way to
> force it to do so?

If the server supports Listings for Machine Processing (MLST or MLSD)
the -X/--request switch lets you use those instead of classical LIST.

Use the -l/--list-only switch to avoid dates entirely. Or you may
want to query a single file's modification time, e.g. for PATH/foo:

curl -v -X "NLST foo" -Q "-MDTM foo" ftp://USER:PASSWORD@DOMAIN/PATH/

should output something that includes the lines

> MDTM foo
< 213 20071118162621

if foo was modified on 2007/11/18 16:26:21.
Received on 2008-01-04