加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

shell 函数法实现监控web 网站url

发布时间:2020-12-15 16:57:42 所属栏目:安全 来源:网络整理
导读:使用shell 函数实现监控web 网站url [root@linux-node3scripts]#catcheckweb.sh#!/bin/bashfunctionusage(){echo$"usage:$0url"exit1}functioncheck_url(){wget--spider-q-o/dev/null--tries=1-T5$1if[$?-eq0]thenecho"$1isyes."elseecho"$1isno."fi}functio

使用shell 函数实现监控web 网站url

[root@linux-node3scripts]#catcheckweb.sh
#!/bin/bash
functionusage(){
echo$"usage:$0url"
exit1
}
functioncheck_url(){
wget--spider-q-o/dev/null--tries=1-T5$1
if[$?-eq0]
then
echo"$1isyes."
else
echo"$1isno."
fi
}
functionmain(){
if[$#-ne1]
then
usage
fi
check_url$1
}
main$*


脚本运行如下

[root@linux-node3scripts]#shcheckweb.sh
usage:checkweb.shurl
[root@linux-node3scripts]#shcheckweb.shwww.baidu.com
www.baidu.comisyes.
[root@linux-node3scripts]#shcheckweb.shwww.baidu89988.com
www.baidu89988.comisno.
[root@linux-node3scripts]#

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读