Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > CL Tool to check for Site Updates?

CL Tool to check for Site Updates?
Thread Tools
headbirth
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Aug 8, 2005, 08:36 PM
 
Can anyone suggest a method for checking on whether a site has been updated via the commandline?
     
rwhiffen
Junior Member
Join Date: Dec 2000
Location: Arlington, VA - USA
Status: Offline
Reply With Quote
Aug 9, 2005, 10:01 AM
 
The curl util will do that for you:
http://curl.haxx.se/ is where you can D/L it. There's a binary version for Mac OS X so you dont' have to compile it yourself. It's also in fink, probably darwin ports too.

Once you have it installed, You can do something like:

[rwhiffen:~] rwhiffen% curl -I http://whiffen.org
HTTP/1.1 200 OK
Date: Tue, 09 Aug 2005 13:57:03 GMT
Server: Apache/1.3.33 (Unix) FrontPage/5.0.2.2635 mod_ssl/2.8.22 OpenSSL/0.9.7d PowWeb/1.1
Last-Modified: Mon, 08 Aug 2005 03:05:06 GMT
ETag: "305aeb1-167d-42f6cbe2"
Accept-Ranges: bytes
Content-Length: 5757
Content-Type: text/html

[rwhiffen:~] rwhiffen%

You can use grep to get just the line you need:
[rwhiffen:~] rwhiffen% curl -sI http://whiffen.org | grep "Last-Modified"
Last-Modified: Mon, 08 Aug 2005 03:05:06 GMT
[rwhiffen:~] rwhiffen%

Further, cut can be used to trim it even more:
[rwhiffen:~] rwhiffen% curl -sI http://whiffen.org | grep "Last-Modified" | cut -b16-80
Mon, 08 Aug 2005 03:05:06 GMT
[rwhiffen:~] rwhiffen%

You can assign that to a variable if you need to:
[rwhiffen:~] rwhiffen% setenv LAST_MOD `curl -sI http://whiffen.org | grep "Last-Modified" | cut -b16-80`
[rwhiffen:~] rwhiffen% echo $LAST_MOD
Mon, 08 Aug 2005 03:05:06 GMT
[rwhiffen:~] rwhiffen%

The ` is the quote above the tab key with the ~ char.

Cheers,

Rich
     
rwhiffen
Junior Member
Join Date: Dec 2000
Location: Arlington, VA - USA
Status: Offline
Reply With Quote
Aug 9, 2005, 10:05 AM
 
After reading the question again, I think it might be simpler to do

curl -z <time> http://some-url

From the curl manual:
TIME CONDITIONS

HTTP allows a client to specify a time condition for the document it
requests. It is If-Modified-Since or If-Unmodified-Since. Curl allow you to
specify them with the -z/--time-cond flag.

For example, you can easily make a download that only gets performed if the
remote file is newer than a local copy. It would be made like:

curl -z local.html http://remote.server.com/remote.html

Or you can download a file only if the local file is newer than the remote
one. Do this by prepending the date string with a '-', as in:

curl -z -local.html http://remote.server.com/remote.html

You can specify a "free text" date as condition. Tell curl to only download
the file if it was updated since yesterday:

curl -z yesterday http://remote.server.com/remote.html

Curl will then accept a wide range of date formats. You always make the date
check the other way around by prepending it with a dash '-'.



One of these two will probably do what you want.

Rich
     
headbirth  (op)
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Aug 10, 2005, 08:45 PM
 
Thanks ... I think curl is already installed in X isn't it??? I do have wget installed, off-hand do you know if it could check for an update?
     
   
 
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -4. The time now is 07:57 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,