13916729435 发表于 2018-8-19 08:09:22

第13章代码《跟老男孩学习Linux运维:Shell编程实战》

# for n in `ls *.sh`;do echo;echo;echo "# cat $n";cat $n;done  

  

  
# cat 10_7_2.sh
  
#!/bin/bash
  
# this script is created by oldboy.
  
# e_mail:31333741@qq.com
  
# function:case example
  
# version:1.3
  
. /etc/init.d/functions
  
check_count=0
  
url_list=(
  
http://blog.oldboyedu.com
  
http://blog.etiantian.org
  
http://oldboy.blog.51cto.com
  
http://10.0.0.7
  
)
  

  
function wait()
  
{
  
echo -n '3秒后,执行检查URL操作.';
  
for ((i=0;i&1
  
if [ $? -eq 0 ]
  
then
  
   action "${url_list[$i]}" /bin/true
  
else
  
   action "${url_list[$i]}" /bin/false
  
fi
  
done
  
((check_count++))
  
}
  
main(){
  
while true
  
do
  
check_url
  
echo "-------check count:${check_count}---------"
  
sleep 7
  
done
  
}
  
main
  

  

  
# cat 13_1_1.sh
  
#!/bin/sh
  
array=(1 2 3 4 5)
  
for((i=0;i
页: [1]
查看完整版本: 第13章代码《跟老男孩学习Linux运维:Shell编程实战》