modifié : creatusr.py

This commit is contained in:
root 2024-10-04 09:46:36 +02:00
parent c9237e9bf3
commit e4d5860326

View File

@ -7,7 +7,11 @@ def create_user(login, nomcomplet):
cmds = ["useradd", "-m", "-c", nomcomplet, "-s", "/bin/bash", login]
res = subprocess.run(cmds,stdout=subprocess.PIPE)
print ("createusr : utilisateur ", login, " cree")
res=subprocess.run(["pwgen", "8", "1"],stdout=subprocess.PIPE)
pw = res.stdout.decode('utf8')
print (pw)
cmds = ["echo", login , ":" ,pw, "chpasswd"]
cmds = ["echo", login , ":" ,pw >> users.txt.pw]
if len(sys.argv) != 2 :
print ("usage : ", sys.argv[0], " <fichier>")
exit (1)