my love for the mystical and magical cURL

begin snippet:

function port {
        if [ $? -ne 0 ] ; then
                printf "warning: "
                        if [ $? -eq 6 ]; then
                                echo "cant resolve host"
                        fi
                if [ $? -eq 7 ]; then
                        echo "cant connect to host"
                fi
                printf "site may be down\n"
        else
                printf "site is up\n"
        fi
        }

curl -s ${1} | egrep 30[0-9] >/dev/null
port;

so for the one or two of you that actually read this site, you may recognize that snippet from a few posts ago.
but i have learned to love cURL and errorlevels when used in conjunction. that function above (a crude one at that) has already saved my ass because of the errorlevel output.

it sounds lame, i know. but you are reading this site so it must have peaked your interest regardless of the lame factor.

«
»

    Leave a Reply

    Your email address will not be published. Required fields are marked *