The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-07-2008
CraigMoore CraigMoore is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 3
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...
  #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,884
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
Sponsored Links
Closed Thread

Bookmarks

Tags
remote file update

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:22 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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