#!/bin/bash
:<<eof
1.能够使用函数
2.能够用curl进行判断
3.通过http状态码进行判断网站是否存活
4.测试是否实现网站地址存活的判断
eof
web_check()
{
echo $1
http_code=$(curl -I -o /dev/null -s -w %{http_code} http://$1)
if [ ${http_code} -eq 200 ]; then
echo "$1 is ok"
else
echo "$1 web not ok"
fi
}
read -p "请输入你想要的监测的网站:" url
web_check $url #调用函数
shell-监测网站地址存活
最新推荐文章于 2023-04-11 21:53:07 发布