Skip to content

Instantly share code, notes, and snippets.

@TheHiddenHaku
Created July 3, 2015 06:55
Show Gist options
  • Save TheHiddenHaku/2e25cbc7f6bea99f0211 to your computer and use it in GitHub Desktop.
Save TheHiddenHaku/2e25cbc7f6bea99f0211 to your computer and use it in GitHub Desktop.
ping url then check for 404
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