check_call(['useradd', 'test'])
proc = Popen(['passwd', 'test'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
proc.stdin.write('password\n')
proc.stdin.write('password')
proc.stdin.flush()
stdout, stderr = proc.communicate()
print(stdout)
print(stderr)
How can I set a users password in linux from a python script?