The Shell function method implements the monitoring web site URL

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.