Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement