I necesitaba una mejor respuesta para esto, así que escribí el guión a continuación.
La fakePhrase se utiliza para detectar las resposnes HTTP del adware "Search Assist" del ISP.
#!/bin/bash
fakePhrase="verizon"
siteList=(
'http://google.com'
'https://google.com'
'http://wikipedia.org'
'https://wikipedia.org'
'http://cantgettherefromhere'
'http://searchassist.verizon.com'
)
exitStatus=0
function isUp {
http=`curl -sL -w "%{http_code}" "$1" -o temp_isUp`
fakeResponse=`cat temp_isUp | grep $fakePhrase`
if [ -n "$fakeResponse" ]; then
http=$fakePhrase
fi
case $http in
[2]*)
;;
[3]*)
echo 'Redirect'
;;
[4]*)
exitStatus=4
echo "$1 is DENIED with ${http}"
;;
[5]*)
exitStatus=5
echo "$1 is ERROR with ${http}"
;;
*)
exitStatus=6
echo "$1 is NO RESPONSE with ${http}"
;;
esac
}
for var in "${siteList[@]}"
do
isUp $var
done
if [ "$exitStatus" -eq "0" ]; then
echo 'All up'
fi
rm temp_isUp
exit $exitStatus
Por favor, no alteran la cuestión y añadir la respuesta, desde el aceptada las personas responderán sabrán qué solución funcionó. –
No entiendo por qué me advirtió que no edite la pregunta. Hasta donde sé, aún no lo he editado. –
Agregaste tu solución a la pregunta; Invertí tu actualización. –