#!/bin/bash
[ -f /etc/init.d/functions ] && . /etc/init.d/functions
function usage(){
echo "USAGE:$0 url"
exit 1
}
RETVAL=0
function CheckUrl(){
wget -T 10 --spider -t 2 $1 &>/dev/null
RETVAL=$?
if [ $RETVAL -eq 0 ];then
action "$1 url" /bin/true
else
action "$1 url" /bin/false
fi
return $RETVAL
}
function main(){
if [ $# -ne 1 ];then
usage
fi
CheckUrl $1
}
main $*
转载于:https://www.cnblogs.com/zhangsubai/p/6811238.html