I'm new in Python, i don't know my subject is correct or wrong. I have
problem with my script. I want to change password with passwd password
in python without user submitted anything from keyboard. I get
tutorial that i must use pipe to process this. And this is my code :
Expand|Select|Wrap|Line Numbers
- 1.
- 2. #!/usr/bin/python
- 3.
- 4. import os
- 5.
- 6. COMMAND = 'passwd'
- 7. PASSWD = 'mypassword'
- 8.
- 9. # open a pipe to passwd program and
- 10. # write the data to the pipe
- 11. p = os.popen("%s" % COMMAND, 'w')
- 12. p.write(PASSWD)
- 13. p.write('\n')
- 14. p.write(PASSWD)
- 15. p.close()
- 16.
but i got this error :
[output]
[cp@server cp]$ ./password
Changing password for user cp.
Changing password for cp
(current) UNIX password: passwd: Authentication token manipulation error
[/output]
Anyone can help me how to write to pipe.. i try several method, and always fail.
Thank's
--
Dhika Cikul