This doesn't answer your question, but it might solve your problem:
You might want to see if your system has a chpass or pw command. chpass lets you change an account's password by specifying an encrypted password on the command line, which would alleviate your need for passwd completely.
However, because the encrypted password is specified on the command line, be aware that it may show up on your system's process list. It may not be a good idea to do this on a system with untrusted users, if those users are allowed to get info about processes they don't own. In this case, your method would be better, but unfortunately I don't have enough experience with the Expect module to help you very much :)