Last active
January 15, 2019 18:23
-
-
Save mihow/4c5481cfb678f87975b03e4f56fc273e to your computer and use it in GitHub Desktop.
Test a URL in bash script and exit on failure or return failure exit code.
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 | |
set -o errexit | |
curl --fail --show-error --location http://httpbin.org/status/200 > /dev/null | |
echo "It worked!" | |
curl --fail --show-error --location http://httpbin.org/status/500 > /dev/null | |
echo "It failed, but you will never see this message." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment