change passwd remotely in solaris 10

i'm trying to change passwd remotely in unix (solaris) and tried using "expect" but it is not working.

Any ideas to change the passwd remotely using a shell script?

set your encrypted password, and use sed to replace it

sed -s '/oldpass/newpass' /etc/shadow > /etc/shadow.new
cp -p /etc/shadow /etc/shadow.Orig
cp -p /etc/shadow.new /etc/shadow

this assumes that you set the password on a local box, and you can get the encrypted passwd from the local /etc/shadow...

Also assumes that no two users have the same password...