So I have this file server for this school. Basically, every student uses one public login for windows and ubuntu alike. They use a custom app to login to the Samba Ubuntu Server using their own password to get to their personal directory. Once and a while they will need to change their password for this login. I need a way to change someones password that is thorough enough so that a bash script could do it, both for samba smbpasswd and ubuntu's passwd. So to sum this up, I need to know what command could be used to change someones password with no-user intervention using a bash script. Because when you type passwd username, then it asks you to type the password, I want a bash script to do this for me, so that when users want to change their password, I just need to edit that bash script. Im looking for something like "passwd user --current-password=CURRENTPASS --new-password=NEWPASS" and it would return ON THAT LINE. I also need it to work for smbpasswd so samba can change its password too.
EDIT Found it! Wow this is great, which I knew this earlier. Using the following command works:
echo -e "newpass\nnewpass" | (smbpasswd -s username)
echo -e "newpass\nnewpass" | (passwd --stdin username)
Of course you would need to add the old password too if you were not running root. I love solving my own problems!