The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
TAHI Test Suite 3.0.15 (IPv6 Conformance Test Tool branch) iBot Software Releases - RSS News 0 07-10-2008 03:50 AM
update a file with values from other file in shell bash teodora Shell Programming and Scripting 1 07-03-2008 08:39 AM
TAHI Test Suite 3.0.13 (IPv6 Conformance Test Tool branch) iBot Software Releases - RSS News 0 04-06-2008 09:20 AM
Keithley Introduces Linux-Based RF Parametric Test Systems - Test and Measurement.com iBot UNIX and Linux RSS News 0 07-23-2007 07:30 AM
how to test for file existence using file size? forevercalz Shell Programming and Scripting 3 10-26-2005 07:02 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-07-2008
Registered User
 

Join Date: Jul 2007
Posts: 1
How to test for file update

I would like to test if a file has been updated from a website located here:

I-BlockList

Is there anyway to do this from the command line (I'd like to add it to a script). I'd just like to either:

(a) See if the file has been updated by looking at the file's 'Date Modified' or

(b) Compare the file size with one I have downloaded earlier.

Of course the file is located on a remote server so you can't use the usual 'ls' commands, and if you use wget, then you'll download it, which may not be necessary if the file hasn't be updated...

Thanks in advance for your help.

Craig

Last edited by DukeNuke2; 10-07-2008 at 01:25 AM. Reason: removed link...
Reply With Quote
Forum Sponsor
  #2  
Old 10-07-2008
otheus's Avatar
Moderator ala Mode
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 605
The utility "wget" already does what you want to do. Check it out using the -N option. If the copy you have is older than the timestamp the webserver gives for the specified URL, a new copy is downloaded. If the file sizes do not match, a new copy is downloaded.

If you don't want it to actually download, but see what it would, do, you can use --spider. Then it reports what it would have done:
Code:
$ wget -N -v http://www.keepalived.org/documentation.html
--16:35:14--  http://www.keepalived.org/documentation.html
Resolving www.keepalived.org... 213.228.1.83
Connecting to www.keepalived.org|213.228.1.83|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5035 (4.9K) [text/html]
The sizes do not match (local 0) -- retrieving.

--16:35:15--  http://www.keepalived.org/documentation.html
Reusing existing connection to www.keepalived.org:80.
HTTP request sent, awaiting response... 200 OK
Length: 5035 (4.9K) [text/html]
Saving to: `documentation.html'

100%[=======================================>] 5,035       --.-K/s   in 0.07s

16:35:15 (68.6 KB/s) - `documentation.html' saved [5035/5035]

[otheus] ~$ touch documentation.html
[otheus] ~$ wget -N -v http://www.keepalived.org/documentation.html
--16:36:08--  http://www.keepalived.org/documentation.html
Resolving www.keepalived.org... 213.228.1.83
Connecting to www.keepalived.org|213.228.1.83|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5035 (4.9K) [text/html]
Server file no newer than local file `documentation.html' -- not retrieving.

[otheus] ~$ echo test >> documentation.html
Change the file size of documentation.html
[otheus] ~$ wget --spider -N -v http://www.keepalived.org/documentation.html
--16:36:27--  http://www.keepalived.org/documentation.html
Resolving www.keepalived.org... 213.228.1.83
Connecting to www.keepalived.org|213.228.1.83|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5035 (4.9K) [text/html]
The sizes do not match (local 0) -- retrieving.

--16:36:27--  http://www.keepalived.org/documentation.html
Reusing existing connection to www.keepalived.org:80.
HTTP request sent, awaiting response... 200 OK
Length: 5035 (4.9K) [text/html]
200 OK
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
remote file update

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:15 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0