I have some simple scripts that are designed to sequentially chain together to run a specific script on a variety of servers, all of which are listed in the file, one per line.
The deployment of a single server 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 install tomcat and symlinks hasoop / hbase configs in a shared class directory.
The second main file is deploy-all.sh, which is designed to analyze the list of hosts and launch the deployment script for 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
It happens that the script is run once, and then the for loop breaks off ... 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 on ssh commands, the loop runs successfully across all 4 hosts, so I assume this is something related to disabling stdio after ssh happens. Also, the tcgatattr error concerns me somewhat.
How can I get around this? What exactly causes the tcgetattr error (I'm not even sure if this is related)? Actually, not much has been done with shell scripts, so sorry if I miss something really obvious here, any help would be appreciated.
juhanic
source share