Skip to content

Instantly share code, notes, and snippets.

@allyshka
Created October 25, 2016 13:35
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save allyshka/51060e4b846d8a27a76a08ca60056aff to your computer and use it in GitHub Desktop.
Save allyshka/51060e4b846d8a27a76a08ca60056aff to your computer and use it in GitHub Desktop.
#!/bin/bash
display_usage() {
echo "This script check connection to list of URLs with specified host."
echo -e "\nUsage:\n$0 ipsfile hostname\n"
echo -e "\nExample:\n$0 moz-com.list moz.com\n"
}
if [ $# -le 1 ]
then
display_usage
exit 1
fi
while read -r line; do
response_http=$(curl -H "Host: $2" --connect-timeout 5 --write-out "code: %{http_code}, length: %{size_download}, redirect: %{redirect_url}" --silent --output /dev/null -k http://$line)
response_https=$(curl -H "Host: $2" --connect-timeout 5 --write-out "code: %{http_code}, length: %{size_download}, redirect: %{redirect_url}" --silent --output /dev/null -k https://$line)
echo "HTTP: $line response [ $response_http ]"
echo "HTTPS: $line response [ $response_https ]"
done < "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment