验证网址是否可用

判断网址是否正常##

#!/bin/bash
array=(
	www.baidu.com
	www.sohu.com
	www.google.com
	www.helloworldxhn.com
)

for url in ${array[*]}
do
	res_code=$(curl -I -m 2 $url 2>/dev/null | egrep 200 | wc -l)
	if [ $res_code -eq 1 ]; then
		echo "$url is successful "
	else
		echo "$url is failure"
	fi
done

curl -I 只显示头部
-m 设置最大读取时间

posted @ 2018-10-11 15:32  徐~某~某  阅读(281)  评论(0编辑  收藏  举报