6 Jan 2012 skvidal   » (Master)

copy if changed

I had written a bunch of versions of something like this for scripts over the years. Had to do it again, yesterday, and decided I’d do it ‘properly’ this time.

http://skvidal.fedorapeople.org/misc/copy_if_changed.py

It downloads from a url and copies to whatever you specify.

Summary:

copy_if_changed – copy file from a remote url to local destination. Return 0
if file has changed, 1 if it hasn’t and 2 if an error occurs

usage is: copy_if_changed url /some/local/destination

Really handy in shell scripts:


if copy_if_changed http://server/some/file /etc/some/file; then
run_something_here
fi

Other features:
- it makes a unique (timestamped) backup of the dest file before it copies it over.
- it uses sha256 for the checksumming

Not sure if it is useful to anyone else but I’m tired of rewriting the same thing.


Syndicated 2012-01-06 19:14:40 from journal/notes

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!