1. 程式人生 > >URL檢測腳本

URL檢測腳本

lena filename spider file url get $? main /dev/null

#!/bin/bash
# filename : 8_5_1.sh
function usage(){
echo "usage:$0 url"
exit 1
}

function check_url(){
wget --spider -q -o /dev/null --tries=1 -T 5 $1
if [ $? -eq 0 ];then
echo "$1 is yes"
else
echo "$1 is no"
fi
}

function main(){
if [ $# -ne 1 ];then
usage
fi
check_url $1
}

main $*

URL檢測腳本