/usr/share/doc/python-utmp/examples/last-old.py is in python-utmp 0.8.3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #!/usr/bin/python
# poor man's last
import utmp
from UTMPCONST import *
import time
a = utmp.UtmpRecord(WTMP_FILE)
print "%-10s %-10s %-30s %-20s" % ("USER", "TTY", "HOST", "LOGIN")
while 1:
b = a.getutent()
if not b:
break
if b[0] == USER_PROCESS:
print "%-10s %-10s %-30s %-20s" % (b[4], b[2], b[5], time.ctime(b[8][0]))
a.endutent()
|