I was excited to find this, so I am saving it here.
To change an smb passwd in a bash script:
echo -e "newpasswd\nnewpasswd" | (smbpasswd -s username)
And note the "\n" in there to push a newline between the two passwords...
For the unix (Linux) username:
echo -e "newpass\nnewpass" | (passwd --stdin username)