The autopasswd script included with tcl/tk doesn't work at all because it sends the password before passwd starts listening for a password. This results in the script just hanging. Even if it did work, certain passwords (eg. those beginning with a hyphen) cannot be set because the password is interpreted as an option to "send". The replacement script below fixes both of the above problems. I don't know if the 0.1s sleep is sufficient in all cases, but I've not had it fail for me yet. #!/usr/bin/expect -- # wrapper to make passwd(1) be non-interactive # username is passed as 1st arg, passwd as 2nd set password [lindex $argv 1] spawn passwd [lindex $argv 0] expect "password:" sleep 0.1 send -- "$password\r" expect "password:" sleep 0.1 send -- "$password\r" expect eof
*** This bug has been marked as a duplicate of 4768 ***
I don't think this bug is resolved. Bug 4768 has nothing to do with autopasswd. Although the timing issue seems to have gone away in later releases of RHL, the problem with not being able to put in passwords beginning with hyphens is still present.
Should be fixed in expect-5.38.0-76.
Closing for now. Please re-open if there are still problems.