Created
October 25, 2016 13:35
-
-
Save allyshka/51060e4b846d8a27a76a08ca60056aff to your computer and use it in GitHub Desktop.
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 | |
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