From fadsf, 7 Months ago, written in Plain Text.
  1. #!/bin/bash
  2.  
  3. #This will write "ttyS0" to /sys/module/kgdboc/parameters/kgdboc to enable kdb
  4. USERNAME=root
  5. HOSTS="172.16.1.142" # Use space as delimeter for multiple hosts "host1 host2 host3"
  6. SCRIPT= $1
  7. if [ -z "$SCRIPT" ]
  8. then
  9.         echo "Usage: executeRemoteScript.sh scriptToExecute.sh"
  10. fi
  11. for HOSTNAME in ${HOSTS}; do
  12.         echo "Execute script"
  13.         echo "${1}"
  14.         echo "on Machine ${USERNAME}@${HOSTNAME}"
  15.         ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -l ${USERNAME} ${HOSTNAME} 'bash -s' < "${SCRIPT}"
  16.         echo "Finished"
  17. done
captcha