您的位置:首页 > 文档 > Shell >
 文章分类 

shell脚本问题


创建:2005-10-26 00:49:45
作者:Unlinux
来自: http://www.Unlinux.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



转载自:http://www.unlinux.com/doc/shell/20051026/219.html

评论】 【加入收藏夹】 【 】 【打印】 【关闭
 *  请尊重我们的劳动,转载请注明出自UnLinux.Com及作者名 * 

※ 相关链接
 ·shell用法  (2005-10-26 00:49:45)
 ·shell中循环取出文件中每一行赋予一变量的问题  (2005-10-26 00:49:45)
 ·shell中的行和列  (2005-10-26 00:49:45)
 ·shell版俄罗斯方块  (2005-10-26 00:49:45)
 ·Shell编程  (2005-10-26 00:49:45)
 ·shell参数问题,linux  (2005-10-26 00:49:45)
 ·Shell递归程序设计/批量转换大写文件名为小写  (2005-10-26 00:49:45)
 ·shell的问题  (2005-10-26 00:49:45)
 ·Shell的魅力  (2005-10-26 00:49:45)
 ·Shell高级屏幕输出  (2005-10-26 00:49:45)

Copyright © 2005 UnLinux.Com All Rights Reserved