for-loop in shell between hosts (with ssh) -
i have loop go through other amazon instances:
#!/bin/bash list="ec2xxxa.compute.amazonaws.com ec2xxxb-central-1.compute.amazonaws.com" sshkey="ssh -tt -i key.pem centos@" in $list; ${sshkey}$i hostname
now try loop through list , print hostname of 2 instances of amazon. works first one. after loop doesn't go further:.
./script.sh ip-172-xx-xx-01 connection ec2-xxxa-1.compute.amazonaws.com closed. last login: thu jan 28 14:09:48 2016 ip-172-xx-xx-01.compute.internal [centos@ip-172-xx-xx-01 ~]$
so can see it's telling me closed connection after closing connection prompt shows ip of host again. have type exit
, after it, goes further following host (which have exit).
adding exit
in script did not help. it's stopping after first host.
try removing -tt
option command.
Comments
Post a Comment