You can script password changes in linux by using passwd without any additional effort. The syntax for this is:
echo "your-password" | passwd --stdin user