我想执行以下代码,但是在vi中用红色突出显示代码中的错误。收到错误后须藤的ssh -t根@ $ IP << EOF线。哪里有我错脚本?
#!/bin/bash
cassandra_home=$(python -c "import json; print \",\".join(json.load(open('${repair.json}','r'))[\"cassandra_home\"])")
iplist[@]=$(python -c "import json; print \",\".join(json.load(open('${repair.json}','r'))[\"iplist\"])")
for ip in ${iplist[@]}
do
sudo ssh -t root@$ip << EOF
for ip in ${iplist[@]}
do
echo Checking $ip for ongoing repairs
${cassandra_home}nodetool -h $ip tpstats | grep Repair#
response=$?
if [ $response -eq 0 ]; then
repair_ongoing=true
echo "Ongoing repair on $ip"
fi
done
if ! [ $repair_ongoing ]; then
## echo "Taking a snapshot."
## ${cassandra_home}bin/nodetool -h $ip snapshot
echo "Starting repair on $ip"
start=$(date +%s)
${cassandra_home}bin/nodetool -h $ip repair -pr -inc -local metadata
sleep 3
${cassandra_home}bin/nodetool -h $ip cleanup metadata
end=$(date +%s)
#echo "ks.tab,st,et,last run,status">>repair_status.csv
echo "Repair and cleanup completed for metadata in $((end - start)) seconds"
fi
exit 0
EOF
done
使用https://www.shellcheck.net/(有一个vim插件),它将告诉您
Line 18:
EOF
^-- SC1039: Remove indentation before end token (or use <<- and indent with tabs).
然后继续列出许多其他问题。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句