Change unix password with Python
Posted by cikul | Posted in Python | Posted on 11-01-2007-05-2008
2
Do you ever have problem while execute /usr/bin/passwd from your python code? actually i have problem with changing unix password from my python code.
First i try using pipe to control output from /usr/bin/passwd, hopefully i can send text with write() function.
this is the code :
#!/usr/bin/python
import os
COMMAND = 'passwd'
PASSWD = 'mypassword'
# open a pipe to passwd program and
# write the data to the pipe
p = os.popen("%s" % COMMAND, 'w')
p.write(PASSWD)
p.write('n')
p.write(PASSWD)
p.close()
But i failed to change the password.
The solution is use Pexpect
Read the rest of this entry »
Incoming search terms:
change user password python | change linux password with python | python change password linux | program python | change user password in python | change unix password web python | change password script python | change password python | change passwd from python | python change user password |Share and Enjoy
