20.07.2011, 11:05
Expect allows you to "feed" the password to the passwd command.
http://linux.die.net/man/5/passwd
http://linux.die.net/man/1/expect
EDIT: Small script that might help
Place this script in /usr/bin and name it setpasswd. You can then call the command setpasswd username password in your PHP function or exec().
http://linux.die.net/man/5/passwd
http://linux.die.net/man/1/expect
EDIT: Small script that might help
Код:
#!/usr/bin/expect -f spawn passwd [lindex $argv 0] set pass [lindex $argv 1] expect { password: {send "$pass\r" ; exp_continue} eof exit }