Ajout du tp sur python
This commit is contained in:
22
sisr2/sisr/35-python/delusers.py
Normal file
22
sisr2/sisr/35-python/delusers.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
filename = "users.txt"
|
||||
|
||||
try:
|
||||
fh = open(filename, "r")
|
||||
except:
|
||||
print ("Fichier ", filename, " inconnu")
|
||||
else:
|
||||
line = fh.readline ()
|
||||
while line:
|
||||
# use realine() to read next line
|
||||
maligne = line.rstrip()
|
||||
(login, name) = maligne.split(":")
|
||||
uncmds = ["userdel", "-r", login ]
|
||||
res = subprocess.run(uncmds,stdout=subprocess.PIPE)
|
||||
line = fh.readline()
|
||||
fh.close()
|
||||
Reference in New Issue
Block a user