modifié : creatusr.py
This commit is contained in:
parent
c9237e9bf3
commit
e4d5860326
@ -7,7 +7,11 @@ def create_user(login, nomcomplet):
|
|||||||
cmds = ["useradd", "-m", "-c", nomcomplet, "-s", "/bin/bash", login]
|
cmds = ["useradd", "-m", "-c", nomcomplet, "-s", "/bin/bash", login]
|
||||||
res = subprocess.run(cmds,stdout=subprocess.PIPE)
|
res = subprocess.run(cmds,stdout=subprocess.PIPE)
|
||||||
print ("createusr : utilisateur ", login, " cree")
|
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 :
|
if len(sys.argv) != 2 :
|
||||||
print ("usage : ", sys.argv[0], " <fichier>")
|
print ("usage : ", sys.argv[0], " <fichier>")
|
||||||
exit (1)
|
exit (1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user