Created
April 27, 2016 19:45
-
-
Save adamdehaven/6f94e855c44e82a75b7c91b109447414 to your computer and use it in GitHub Desktop.
Bash/Terminal check if a URL can be reached via cURL
This file contains hidden or 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 | |
case "$(curl -s --max-time 2 -I $1 | sed 's/^[^ ]* *\([0-9]\).*/\1/; 1q')" in [23]) echo "HTTP connectivity is up";; 5) echo "The web proxy will not let us through";; *) echo "The network is down or very slow";; esac | |
### Run | |
# $ bash network-connectivity.sh http://google.com/ | |
### Result | |
# $ HTTP connectivity OK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment