linux shell脚本中函数调用问题
下面的代码中怎么在上面的if语句中调用checkall函数,我这样写的有问题,求指点!不甚感激~
#!/bin/bash
processer=$1
if [ $1 = "all" ];then
checkall
fi
checkall()
{
count1=`ps -ef |grep @name |grep -v "grep" |wc -l`
#echo $count1
count2=`ps -ef |grep @name |grep -v "grep" |wc -l`
#echo $count2
if [ $count1 == 0 ] && [ $count2 == 0 ];then
sleep 2
echo "successfully!"
else
echo "failed!"
exit 1
fi
}
#!/bin/bash
processer=$1
if [ $1 = "all" ];then
checkall
fi
checkall()
{
count1=`ps -ef |grep @name |grep -v "grep" |wc -l`
#echo $count1
count2=`ps -ef |grep @name |grep -v "grep" |wc -l`
#echo $count2
if [ $count1 == 0 ] && [ $count2 == 0 ];then
sleep 2
echo "successfully!"
else
echo "failed!"
exit 1
fi
}
...全文


