Ich habe mal wider eine Frage wie kann ich mit Python
ein Linux Root Passwort setzen.
Code: Alles auswählen
def Install():
os.system("sudo passwd")
os.system(rootpass)
os.system(rootpass)
ich komme nicht drauf wie ich es hinbekomme
LG ST
Code: Alles auswählen
def Install():
os.system("sudo passwd")
os.system(rootpass)
os.system(rootpass)
Code: Alles auswählen
def Install():
p=subprocess.Popen("sudo passwd",stdin=subprocess.PIPE,shell=True)
p.communicate(rootpass)
Entschuldige bitte den Weg in die Weg in die Sackgasse.http://docs.python.org/library/subprocess.html#subprocess.Popen.communicate hat geschrieben:Popen.communicate(input=None)
Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional input argument should be a string to be sent to the child process, or None, if no data should be sent to the child.
Code: Alles auswählen
p.communicate('rootpass\nrootpass\n')
Code: Alles auswählen
def SetRootpasswd():
p=subprocess.Popen("sudo passwd",stdin=subprocess.PIPE,shell=True)
p.communicate('rootpass\nrootpass\n')
Punkt Punkt PunktDauerbaustelle hat geschrieben:Vielleicht solltest du auch noch ein <Enter> senden...