Results 1 to 9 of 9
Hello!
I have a problem reading the modification date for files from a LIST response from FTP.
It shows something like this:
drwxr-xr-x 4 username username 4096 Dec 9 22:37 ...
- 01-02-2009 #1Just Joined!
- Join Date
- Dec 2008
- Posts
- 10
How to read the response from LIST command sent to FTP?
Hello!
I have a problem reading the modification date for files from a LIST response from FTP.
It shows something like this:
drwxr-xr-x 4 username username 4096 Dec 9 22:37 .
drwx--x--x 11 username username 4096 Dec 9 22:30 ..
-rw-r--r-- 1 username username 146 Dec 9 22:37 File.js
-rw-r--r-- 1 username username 187 Dec 9 22:34 onefile.html
drwxr-xr-x 3 username username 4096 Dec 9 22:38 sites_html_1
drwxr-xr-x 2 username username 4096 Dec 9 22:36 sites_html_2
-rw-r--r-- 1 username username 142 Dec 9 22:37 test.js
drwxr-x--- 5 username 99 4096 Apr 8 2008 .htpasswds
As you can see, besides the last file, the rest of them have the hour of the last change.
I would like to know after what interval of time the hour dissappears and the year takes its place, so I can calculate the year for the ones that don't show that.
Any help will be highly appreciated!
Best regards,
Ariel
- 01-03-2009 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
if by "ftp" you can connect to a server, then you
can use "ssh" also: then "ls -l" shows year,date,time
&cthe sun is new every day (heraclitus)
- 01-03-2009 #3Just Joined!
- Join Date
- Dec 2008
- Posts
- 10
I connect to FTP using sockets, not the ftp command from SSH.
- 01-05-2009 #4Just Joined!
- Join Date
- Dec 2008
- Location
- e-burgh, PA
- Posts
- 4
The interval is greater than 12 months. Any Month Day and time displayed is the Current Year otherwise it shows Month Day and Year.
--------------------------------------------------------------------------
- 01-06-2009 #5Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
Assuming that ftp LIST uses the same rule as GNU ls, because:
and:Code:ls [remote-directory] [local-file] Print a listing of the contents of a directory on the remote machine. The listing includes any system-dependent informa- tion that the server chooses to include; for example, most UNIX systems will produce output from the command 'ls -l'. -- excerpt from man ftp
For full details, read the sections.Code:10.1.6 Formatting file timestamps By default, file timestamps are listed in abbreviated form. Most locales use a timestamp like `2002-03-30 23:45'. However, the default POSIX locale uses a date like `Mar 30 2002' for non-recent timestamps, and a date-without-year and time like `Mar 30 23:45' for recent timestamps. A timestamp is considered to be "recent" if it is less than six months old, and is not dated in the future. If a timestamp dated today is not listed in recent form, the timestamp is in the future, which means you probably have clock skew problems which may break programs like `make' that rely on file timestamps. The following option changes how file timestamps are printed ... -- excerpt from info coreutils ls
However, if the system to which you are connected is not *nix, I have no idea, and you will need to consult the remote documentation ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 01-06-2009 #6Just Joined!
- Join Date
- Dec 2008
- Posts
- 10
Thanks for the replies.
I assumed it was something about 6 months, judging by some measurements I did. However, this ensures me about my original idea.
Thanks a lot!
- 01-06-2009 #7Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
You are welcome. The man and info pages are powerful sources of information.
A thought -- you could test the field following the date of the month for the inclusion of a ":". If so, then it's not a year.
I don't know if this would help for the responses from all servers, but probably useful for *nix. ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 01-06-2009 #8
ls -l --time-style=<format>
If you just want to calculate the time of that file which is showing just the year not the exact hour/minutues ... then --time-style=long-iso or --time-style=full-iso options in linux "ls" command will suffice this request.
Now, as its showing the exact changed time of that file... you can calculate the elapsed time.Code:[/E*Fare/Users/qabuild/aksutil/P] $ ls -l view.pl -rwxr-xr-x 1 qabuild DENCCEFS 7792 Apr 3 2007 view.pl* [/E*Fare/Users/qabuild/aksutil/P] $ ls -l --time-style=long-iso view.pl -rwxr-xr-x 1 qabuild DENCCEFS 7792 2007-04-03 08:55 view.pl* [/E*Fare/Users/qabuild/aksutil/P] $ ls -l --time-style=full-iso view.pl -rwxr-xr-x 1 qabuild DENCCEFS 7792 2007-04-03 08:55:03.805406000 +0000 view.pl*
asangal
- 01-06-2009 #9Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi, Sangal-Arun.
The OP is getting this from an ftp LIST request. Can you demonstrate how your suggestion would work in that situation? ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )


Reply With Quote