shell - shell脚本问题
shell脚本问题
2004-04-23 15:18 pm来自:Linux文档
现载:Www.8s8s.coM
地址:无名
写了一段程序但有些问题:
有几十台unix系统,我想查硬盘空间,假如有某台机关了或线路不通,如何可以跳过不通的系统继续往下?
centre()
{
rexec computer_$1 df
return
}
if(test $# = 0)
then
clear
for name in `cat tmp1`
do
echo "--------------------------------------------------$name "
centre $name
done
else(test $# = 1)
banner $1
centre $1
fi
可以用ping来检测网络
ping -c 1 $1 1>/dev/null 2>&1
if test $? -ne 0
then
echo "与$1不通"
exit 0
fi
centre()
{
rexec computer_$1 df
return
}
if(test $# = 0)
then
clear
for name in `cat tmp1`
do
echo "--------------------------------------------------$name "
####以下几行新增#####
ping -c 1 $name 1>/dev/null 2>&1
if test $? -ne 0
then
echo "$name不通"
continue
fi
####以上几行新增#####
centre $name
done
else(test $# = 1)
banner $1
centre $1
fi