#!/usr/local/bin/python2.4 URL = 'http://www.openbsd.org/errata42.html' SHA1 = '24a908827642f19ee046db6ca66f3024eb5a457e' import urllib import sha import sys fh = urllib.urlopen(URL) m = sha.new(fh.read()) fh.close() h = m.hexdigest() if h != SHA1: print 'The contents of \'' + URL + '\' have changed.' fh = open(sys.argv[0], 'r+') l = fh.readlines() l[3] = 'SHA1 = \'' + h + '\'\n' fh.seek(0) fh.truncate() fh.writelines(l) fh.close()