I had a project where I wanted to run the same script on multiple servers from a single point. This became a small application that I am not at liberty to share, but at the heart of it was the following command:
cat remote_script | sshpass -p`echo $PASSWORD` ssh root@$LIST bash
So remote_script would be the script I wanted to run. The catch 22 was the script had to use Java style carriage returns in the script and end with an exit command.
The same code would instead look like
hostname -a ;\
uname -a ;\
ls -la ;\