Shell script to run command on multiple servers

This is great script to run commands on multiple servers at once, especially if you have setup password less connections.

!/bin/bash servers="srv1.example.com srv2.example.com srv3.example.com" SSH_PORT=22 cmd=$1 if [ "$cmd" == "" ]; then echo "Usage sh multicmd.sh 'command' " else echo "--------------------------------------------------------" echo "Ready to Execute ${cmd} on Servers." echo "--------------------------------------------------------" echo "Do you want to Continue y/n?" response=head -1 if [ "$response" == "y" ]; then echo " Would you like to execute this command on all Servers?" echo "Are you sure? y/n?" response=head -1 if [ "$response" == "y" ]; then for srv in $servers do clear echo executing $cmd on $server ssh -p $SSH_PORT $srv $cmd; echo execution on $srv done! echo -n "Press Any key..." read -t 3 response done else echo " Enter the hostname or ip of server you wish to run command to" response=head -1 if [ "$response" == "" ]; then echo "You must enter a server to run a command. Please try again!" exit else echo executing $cmd on $srv ssh -p $SSH_PORT $srv $cmd; echo execution on $srv done! fi fi fi fi