LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-23-2006, 09:10 AM   #1
muxman
Member
 
Registered: Apr 2004
Distribution: Debian
Posts: 203

Rep: Reputation: 32
how to make wget user sytem time


How can I make wget use the current system time for the file date and time when it downloads a file? I don't want the date and time that the file has on it's server. I want the date and time I downloaded the file.
 
Old 10-23-2006, 09:52 AM   #2
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
you can touch the file after downloading it to change the time...

Quote:
itg-debian:/home/default# ls -al photoshare-4.2.0.zip
-rw-r--r-- 1 default default 321138 Jun 20 2005 photoshare-4.2.0.zip

itg-debian:/home/default# touch photoshare-4.2.0.zip

itg-debian:/home/default# ls -al photoshare-4.2.0.zip
-rw-r--r-- 1 default default 321138 Oct 23 10:50 photoshare-4.2.0.zip
 
Old 10-23-2006, 09:55 AM   #3
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
Why do you need those time stamps? Any particular reason?

I don't know if wget supports that (it would surprise me, since it doesn't seem logical to me).

Anyway, I'd go with farslayer's suggestion to use "touch".

Last edited by timmeke; 10-23-2006 at 09:57 AM.
 
Old 10-23-2006, 10:07 AM   #4
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Yup, it's an easy way. For an example:
Code:
wget http://someplace.com/somedir/filename_to_get && touch filename_to_get
Or, you could just create a very small scriptlet that takes arguments and passes them to wget, and after that touches the wget'ed file; make that script executable (named like wgett for example) and put it in /usr/bin or some place of your choice. A little more effort the first time, but makes things easier if you do a lot of this.

EDIT: wget seems to have somekind of "execute" option, which might enable you to use touch in conjunction with the wget command itself; with -N option to wget you can (from the man page) enable timestamping, though I'm not sure if this does what you want -- I didn't test it.

I might try wget -N first, then if it doesn't work, the -e (execute) switch and after that piping with touch.

Last edited by b0uncer; 10-23-2006 at 10:11 AM.
 
Old 10-23-2006, 07:07 PM   #5
muxman
Member
 
Registered: Apr 2004
Distribution: Debian
Posts: 203

Original Poster
Rep: Reputation: 32
Quote:
Originally Posted by timmeke
Why do you need those time stamps? Any particular reason?

I don't know if wget supports that (it would surprise me, since it doesn't seem logical to me).

Anyway, I'd go with farslayer's suggestion to use "touch".

It's so that when the files are listed by time, the files downloaded last have he newest date and time on them. For sorting files with similar names, like 11560049 and 11570123 and so on. A directory with 200 files like that can be hard to sort namewise, to the eye. But listed by date and time they are easier to see what data is coming in from the remote location and what files are the newest and most recent.
 
Old 10-24-2006, 01:15 AM   #6
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
To ease the sorting by name, you could use something like:
Code:
ls | sort -n
sort -n orders the entries by their numerical value (ascending), use -r if you want to reverse the order (ie descending).
Numerical sorting is safer than the alphabetical ordering done by "ls", in cases where the filenames consist only of numbers, like your examples.

If I understand you correctly, you want to be able to see which files were downloaded most recently, right? This would indeed mean that you can't just "touch" all your files each time wget finishes, because this would overwrite all last mod times ie making all files appear "equally recent".
Instead, you would only like to change the timestamps of the newly downloaded files.

For this, I propose the following solution:
1. Turn on wget's timestamping (-N) to make sure it downloads only new or updated files from the remote server.
2. Use wget's -o option to write the log to a file. You may also want to use -nv (non-verbose) to keep the amount of log information limited.
3. Use standard tools like grep, cut, awk, sed or simple scripting (ie Perl) to parse the log file.

I used a similar parsing method once, but don't have the script at hand here, unfortunately.
If I remember correctly though, you could simply "grep saved /your/log/file" to get a list of all saved (downloaded files). But this could be different now, since I was using a rather old version of wget at the time.

So, a good approach would be to make wget run with -N and -o (and possibly -nv), then taking a look at the log file created to see which lines you need and then trying to filter these lines out by using grep or awk. Finally, you may want to select the parts of those lines that represent the actual filenames, using tools like cut or sed.
Make sure to test this thoroughly.

Once you get a list of retrieved files from parsing the log, you can simply call "touch" on each of those files via:
Code:
for i in `cat filelist`; do
   touch ${i};
done;
or something similar.

Last edited by timmeke; 10-24-2006 at 01:36 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
First time Linux user, soon to be last time.. rrc124 Linux - Laptop and Netbook 33 05-17-2006 09:46 PM
what is the command to make a user change their password after creating a new user? naweenio Linux - Newbie 7 01-05-2005 07:07 AM
how to user wget jadermf Linux - Software 1 03-04-2004 12:40 PM
How do I make wget-1.9.1 work? akihandyman Linux - Software 2 11-26-2003 02:20 PM
how to make a user an admin so that i dont have to su every time infected Linux - General 6 07-15-2003 09:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration