Using shell functions to implement monitoring web site URLs
[[email protected] scripts]# cat checkweb.sh#!/bin/ Bashfunction 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 "$ is yes. " else echo "$1 is No. " fi}function main () { if [ $# -ne 1 ] then usage fi check_url $1}main $*
The script runs as follows
[[Email protected] scripts]# sh checkweb.shusage:checkweb.sh url[[email protected] scripts]# sh checkweb.sh www.baidu.co M www.baidu.com is yes. [[Email protected] scripts]# sh checkweb.sh www.baidu89988.comwww.baidu89988.com is no.[[email protected] scripts]#
This article is from the "Knowledge Change Destiny" blog, please be sure to keep this source http://ahtornado.blog.51cto.com/4826737/1931787
The Shell function method implements the monitoring web site URL