I have a few simple scripts that are intended to daisy chain together to run a specific script on a set of servers all listed out in a file, one per line.
The single server deploy script contains the following:
1 #!/bin/bash
2
3 file=$1
4 host=$2
5
6 scp ${file} ${host}:/tmp/
7 USER=`whoami`
8 ssh -t -t $USER@${host} /tmp/${file}
9
10 ssh "${host}" /bin/rm /tmp/${file}
11 exit
It works fine on a script I have that yum installs tomcat and symlinks hadoop/hbase configs to the shared class directory.
The second major file is deploy-all.sh which is intended to parse a list of hosts and run the deploy script to all of them:
1 #!/bin/bash
2
3 script=$1
4
5 cat dumbo-hosts | while read fileline
6 do
7 echo ${fileline}
8 ./deploy.sh ${script} ${fileline}
9
10 sleep 10
11 done
What happens is that the script runs once, and then the for loop is broken... I got something like the following output:
$ ./deploy-all.sh setup-tomcat.sh
line is hadoop01.myhost
setup-tomcat.sh 100% 455 0.4KB/s 00:00
tcgetattr: Inappropriate ioctl for device
hadoop02.myhost
hadoop03.myhost
hadoop04.myhost
<succesful output of hadoop01 task>
...
Connection to hadoop01.myhost closed.
If I comment out the ssh commands the loop runs succesfully through all 4 hosts so I presume it's something involving stdio getting cut off once the ssh occurs. In addition the tcgatattr error concerns me somewhat.
How can I get around this? What exactly is causing the tcgetattr error(I'm not even sure if it's related)? Haven't really done much with shell scripts so sorry if I'm missing something really obvious here, any help would be appreciated.