Created
September 2, 2016 20:34
-
-
Save brwyatt/b725d52a8ea1328e57a55f151dbb7729 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
servers=() | |
unset input | |
read -p "Server ${#servers[@]}: " input | |
while [ ${#servers[@]} -eq 0 ] || [[ "x${input}" != "x" ]]; do | |
if [[ "x${input}" != "x" ]]; then | |
servers=("${servers[@]}" $input) | |
fi | |
unset input | |
read -p "Server ${#servers[@]}: " input | |
done | |
read -p 'Username: ' user | |
read -s -p 'Password: ' password | |
echo | |
read -p 'Command: ' cmd | |
for server in ${servers[@]}; do | |
echo "**** Running '${cmd}' on '${server}' as '${user}'..." | |
sshpass -p"${password}" ssh "${user}"@"${server}" "${cmd}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment