#!/bin/bash
#要检测的网站地址
array=(
http://www.baidu.com
http://www.jd.com
)
Wait(){
echo -n "wait 3s "
for((i=0;i<3;i++))
do
echo -n "."
sleep 1
done
echo
}
CheckUrl(){
wget -t 2 -T 5 --spider $1 &> /dev/null
if [ $? -eq 0 ];then
echo -e "\e[1;31;5mcheck $1 is OK\e[0m"
else
echo "check $1 is Failed"
fi
return $?
}
main(){
Wait
for((i=0;i<${#array[*]};i++))
do
CheckUrl ${array[i]}
done
return $?
}
main $*