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 Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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 06:50 AM
update a file with values from other file in shell bash teodora Shell Programming and Scripting 1 07-03-2008 11:39 AM
TAHI Test Suite 3.0.13 (IPv6 Conformance Test Tool branch) iBot Software Releases - RSS News 0 04-06-2008 12:20 PM
Keithley Introduces Linux-Based RF Parametric Test Systems - Test and Measurement.com iBot UNIX and Linux RSS News 0 07-23-2007 10:30 AM
how to test for file existence using file size? forevercalz Shell Programming and Scripting 3 10-26-2005 10:02 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
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 04:25 AM.. Reason: removed link...
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-07-2008
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,770
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

Bookmarks

Tags
remote file update

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:




All times are GMT -4. The time now is 05:41 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66