Created
June 24, 2014 05:50
-
-
Save jmakeig/4a60ddd38647078f5e32 to your computer and use it in GitHub Desktop.
Capture 4xx and 5xx errors as errors with cURL
This file contains 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
#! /bin/bash | |
# --fail: exit with 22 for an HTTP error response | |
# --show-error: write a message to stderr on failure, even with --silent | |
# --silent: don't show progress or errors | |
# -i: include headers in output | |
curl --fail --show-error --silent -i http://httpstat.us/"$1" 1>/dev/null | |
if [[ $? != 0 ]] ; then | |
echo "error" | |
exit 1 | |
fi | |
echo "worked" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Short for
curl -fSsi http://httpstat.us/200