Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.59 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. command=$* #Command to run. Example: aws.sh echo "Hello World!"
  4. exit=0
  5.  
  6. for ID in $(aws autoscaling describe-auto-scaling-instances --region us-east-1 --query AutoScalingInstances[].InstanceId --output text);  do
  7.     for IP in $(aws ec2 describe-instances --instance-ids $ID --region us-east-1 --query Reservations[].Instances[].PrivateIpAddress --output text|awk '{print $4}'); do
  8.         ssh $IP $command  2>&1 >/tmp/out$i  &  
  9.         pids[${i}]=$!.
  10. done
  11.  
  12. for pid in ${!pids[@]}; do
  13.     wait ${pids[$pid]} || { echo Server $pid failed. Output: ; cat /tmp/out$pid ; }
  14. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement