....rather than recreating the wheel, I will point you to a previously published solution here it appears to change both NT and Unix passwords but I suspect you can just strip out what you need, modifying the waitfor() to account for your prompts.
Comment on Re: telnet, passwords, and other challenges to my cough syrup ridden mind