From
[email protected] Thu Dec 18 08:21:36 2008
Path: egsner!news.cirr.com!goblin2!goblin1!goblin.stu.neva.ru!news.motzarella.org!motzarella.org!news.motzarella.org!not-for-mail
From: Keith Thompson <
[email protected]>
Newsgroups: comp.unix.shell
Subject: Re: shell script to download file
Date: Tue, 16 Dec 2008 16:56:26 -0800
Organization: None to speak of
Lines: 36
Message-ID: <
[email protected]>
References: <004641b3-14b6-4362-bbaa-d64e246f7ea2@q30g2000prq.googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.eternal-september.org U2FsdGVkX19aT2WcDYJ4GZt6SI9YTCkk+gJcghze4cs74KYko4bXwrv3l1+xypw3ZTB8C7XBNbVZe7QOuFG+bCDbXZGqSI7XL1W6Z37YTMJ7dXydeK2vUwjWff272PpdslbGl54Qfsc=
X-Complaints-To: Please send complaints to
[email protected] with full headers
NNTP-Posting-Date: Wed, 17 Dec 2008 00:56:29 +0000 (UTC)
X-Auth-Sender: U2FsdGVkX19BoLn3z8LWO/2YsdbEV01d
Cancel-Lock: sha1:cANXHLebMEFwroajiY3GXSeOTFU=
sha1:691yXCEcOlcQ0lrECSSoOCTmJW4=
User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (gnu/linux)
Xref: egsner!news.cirr.com comp.unix.shell:208916
X-IMAPbase: 1230221425 1
Status: O
X-Status:
X-Keywords:
X-UID: 1
"
[email protected]" <
[email protected]> writes:
> I want to download a file from server which is updated after few mins.
>
> So I want to download file every 15 mins and check if it is change or
> not. If it is change then I will make a new copy of that with
> timestamp.
>
> repeat same thing evry 15 mins.
>
>
> how can I do this using shell script ?
What kind of server? I'll assume in the following that it's a web or
ftp server.
I'd use the "curl" command. If you don't have it on your system, you
can get it from <
http://curl.haxx.se/>. Using "curl --head <URL>",
you can get the timestamp and size from the server without actually
downloading the file. Record this information in an auxiliary file;
if it hasn't changed since the last time you checked, don't bother to
download the file. If you don't see "Last-Modified:" and
"Content-Length:" fields in the output of "curl --head", this won't
work.
Depending on your requirements, you might want to download the file to
a temporary location, then rename it once you're sure you have it;
otherwise you risk clobbering your only good copy of something goes
wrong.
Put all this in a script, and run the script from a cron job.
--
Keith Thompson (The_Other_Keith)
[email protected] <
http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"