Solaris knows I'm using pexpect!

Steve Horsley shoot at the.moon
Thu Mar 11 21:33:22 CET 2004


I am trying to automate changing of a password for a particular 
user account (for use by scripts, not people). I am trying to 
use the command "passwd testuser" as root. 
Of course I can do this by hand. I have succesfully 
used pexpect to do this in a script on Linux, a bit like this:

import pexpect
p = pexpect.spawn("/bin/sh")
p.sendline("passwd testuser\r")
pw = randomPassword()
p.sendline(pw + "\r")
p.sendline(pw + "\r")

I skipped the checking code in the above summary.
This works fine on Linux, but on Solaris, the response 
to "passwd testuser" is "Access denied" rather than 
"Enter new password:".

Solaris somehow knows I'm using expect rather than directly 
driving the passwd command, and won't play ball.

Does anyone know how I can automate this password change?

Thanks,
Steve.



More information about the Python-list mailing list