File: remove-old.py

package info (click to toggle)
python-utmp 0.9-1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 196 kB
  • sloc: python: 797; ansic: 583; makefile: 49; sh: 2
file content (20 lines) | stat: -rwxr-xr-x 350 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/python
# remove tty given as argument from utmp file

import utmp, sys
from UTMPCONST import *

a = utmp.UtmpRecord()

line = sys.argv[1]

b = a.getutline_dict(line)
if not b:
    print line, "is not occupied, cannot remove."
    sys.exit()
b['ut_type'] = DEAD_PROCESS
b['ut_line'] = ''
b['ut_user'] = ''
a.pututline_dict(b)
a.endutent()