if os.getuid()!= ROOT_UID: print"Must be root to run this script."
sys.exit(E_NOTROOT)
if len(sys.argv)!= 1:
lines=int(sys.argv[1]) else:
lines=LINES
os.chdir(LOG_DIR)
if os.getcwd()!= LOG_DIR: print"Can't change to %s"% LOG_DIR
sys.exit(E_XCD)
fr = open("messages")
fw = open("mesg.temp","w")
s = fr.readlines()
num_of_lines = len(s) for i in range((num_of_lines-lines),num_of_lines):
fw.write(s[i])
fr.close()
fw.close()
os.rename("mesg.temp","messages")
fr = open("/dev/null")
fw = open("wtmp","w")
ss = fr.read()
fw.write(ss)