Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. servers=()
  4. unset input
  5. read -p "Server ${#servers[@]}: " input
  6. while [ ${#servers[@]} -eq 0 ] || [[ "x${input}" != "x" ]]; do
  7. if [[ "x${input}" != "x" ]]; then
  8. servers=("${servers[@]}" $input)
  9. fi
  10. unset input
  11. read -p "Server ${#servers[@]}: " input
  12. done
  13.  
  14. read -p 'Username: ' user
  15. read -s -p 'Password: ' password
  16. echo
  17. read -p 'Command: ' cmd
  18.  
  19. for server in ${servers[@]}; do
  20. echo "**** Running '${cmd}' on '${server}' as '${user}'..."
  21. sshpass -p"${password}" ssh "${user}"@"${server}" "${cmd}"
  22. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement