#!/bin/sh
usage(){
    echo "Usage:$0 url"
    exit 1
}
checkurl(){
    local num=`curl -I -m 5 -s -w "%{http_code}\n" -o /dev/null $1 | grep -w "200\|301" | wc -l`
    echo $num
    if [ $num -eq 1 ]
    then
        echo "$1 is ok"
    else
        echo "$1 is fail"
    fi
}
main(){
    if [ $# -ne 1 ]
    then
        usage
    fi
    checkurl $1
}
main $*