Skip to content

Instantly share code, notes, and snippets.

@adamdehaven
Created April 27, 2016 19:45
Show Gist options
  • Save adamdehaven/6f94e855c44e82a75b7c91b109447414 to your computer and use it in GitHub Desktop.
Save adamdehaven/6f94e855c44e82a75b7c91b109447414 to your computer and use it in GitHub Desktop.
Bash/Terminal check if a URL can be reached via cURL
#!/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