有时候遇到大量的url需要检查状态码的时候 ,可以用下面的脚本进行检查,
#!/bin/bash#file=domain
read -p "url file:" file
rm -rf code/*
for i in `cat domain`;
do
ipip=`ping $i -c 1 | head -1 | cut -d " " -f 3`
httpcode=`curl -k -o /dev/null -s -m 3 -w %{http_code} $i --referer https://www.baidu.com --user-agent 'Mozilla/5.0 (compatible; Baiduspider-render/2.0; +http://www.baidu.com/search/spider.html)' `
if (( $httpcode == 200 )) ; then
echo -e "\e[32m $httpcode ------ $i \t\t $ipip \e[0m"
elif (( $httpcode == 302 || $httpcode == 301 )) ; then
echo -e "\e[35m $httpcode ------ $i \t\t $ipip \e[0m"
elif (( $httpcode == 400 || $httpcode == 403 || $httpcode == 401 || $httpcode == 404 )) ; then
echo -e "\e[33m $httpcode ------ $i \t\t $ipip \e[0m"
elif (( $httpcode == 500 || $httpcode == 502 || $httpcode == 503 )) ;then
echo -e "\e[31m $httpcode ------ $i \t\t $ipip \e[0m"
else
echo -e "\e[37m $httpcode ------ $i \t\t $ipip \e[0m"
fi
echo -e $i "\t\t" $ipip >> code/$httpcode
done
下载