setting passwd in script

You could obtain expect at The HP-UX Porting and Archive Centre. As for sam, it is interactive by nature. But it uses an undocumented feature. /usr/sam/lbin/useradd.sam is a symlink to useradd. userradd checks its name. If it's useradd.sam, a -p option becomes available. However the argument must be the encrypted password. It's hard to encrypt a password in a ksh script. But this might be an ioption if you have the encrypted string. Also I wrote a script that uses telnet to change passwords on multiple systems. That technique could be used to change a password on the localhost.

changepass automate password changes on multiple systems