Skip to content

Instantly share code, notes, and snippets.

@zhimsel
Last active August 29, 2015 14:01
Show Gist options
  • Save zhimsel/6e179bd058cb04143f5a to your computer and use it in GitHub Desktop.
Save zhimsel/6e179bd058cb04143f5a to your computer and use it in GitHub Desktop.
#!/bin/bash
# define some functions
######################################
# command
run_command () {
echo ""
echo "----------------------"
echo "Running '$COMMAND' on $SERVER"
echo "$COMMAND" | ssh "$SSH_OPTIONS" "$SERVER" /bin/bash
}
######################################
# if next arg is a file, then use that as the list of servers
# otherwise use the remaining args as your server list
# and then do it!
if [ -f "$1" ]; then
while read SERVER; do
run_command
done < "$1"
else
for SERVER in "$@"; do
run_command
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment