Created
July 3, 2015 06:55
-
-
Save TheHiddenHaku/2e25cbc7f6bea99f0211 to your computer and use it in GitHub Desktop.
ping url then check for 404
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
read -e -p "Inserisci il server/dominio da controllare: " yourURL | |
read -e -p "Ora inserisci il percorso sul server da aprire: " yourPath | |
((count = 1000000)) # Maximum number to try. | |
while [[ $count -ne 0 ]] ; do | |
ping -c 1 "$yourURL" # Try once. | |
rc=$? | |
if [[ $rc -eq 0 ]] ; then | |
((count = 1)) # If okay, flag to exit loop. | |
fi | |
echo "Ping Timeout. Dominio non risolve o è protetto." | |
((count = count - 1)) # So we don't go forever. | |
done | |
if [[ $rc -eq 0 ]] ; then # Make final determination. | |
while [ 1 ] | |
do | |
if curl --output /dev/null --silent --head --fail "http://$yourURL$yourPath" | |
then | |
echo "Url trovata! Apriamo il sito" | |
open "http://$yourURL$yourPath" | |
exit | |
else | |
echo "Il dominio risolve, ma restituisce errore (Url non trovata)" | |
fi | |
done | |
else | |
echo "Ping Timeout. Dominio non risolve o è protetto." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment