【发布时间】:2011-10-13 01:44:05
【问题描述】:
我有这个脚本在 4 个服务器上执行 scp 并在调用服务器上获取文件,但是当我运行它时出现以下错误:
syntax error near unexpected token `then'
line 16: `if[[ $line = $texts ]] ; then
代码如下:
#!/bin/sh
servers=("root@67.215.227.233" "root@57.245.127.134" "root@67.215.127.135" "root@116.244.128.153")
tlen=${#servers[@]}
count=o
total=0
texts="Untar done you can upload new .tar file"
for(( i=0; i<${tlen}; i++ ));
do
echo "in"
scp ${servers[$i]}:/usr/site/html/test/test.txt /mnt/backups/updateimage
cat test.txt ; while read line
do
echo "in"
let count++
echo "$line"
if[[ $line = $texts ]] ; then
echo "true"
let total++
else echo "false"
fi
done < test.txt
done
exit 0
【问题讨论】:
标签: unix shell ssh remote-access scp