#!/usr/bin/env python import os, fcntl fd = os.open("/tmp/exploit-counter", os.O_RDWR | os.O_CREAT, 0644) fcntl.lockf(fd, fcntl.LOCK_EX) f = os.fdopen(fd, "w+") n = int(f.read()) + 1 f.seek(0) f.write(str(n)) f.close() print "Content-type: text/plain\r\n\r\n... but not today, eh?", n