Skip to content

Instantly share code, notes, and snippets.

@TheHiddenHaku
Created July 3, 2015 06:55
Show Gist options
  • Select an option

  • Save TheHiddenHaku/2e25cbc7f6bea99f0211 to your computer and use it in GitHub Desktop.

Select an option

Save TheHiddenHaku/2e25cbc7f6bea99f0211 to your computer and use it in GitHub Desktop.

Revisions

  1. TheHiddenHaku created this gist Jul 3, 2015.
    29 changes: 29 additions & 0 deletions pingandchec404
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    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