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.
This is great script to run commands on multiple servers at once, especially if you have setup password less connections.
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