Skip to content

Instantly share code, notes, and snippets.

@nabe256
Created April 11, 2017 06:01
Show Gist options
  • Save nabe256/3a7bb15b81282c6e39c2736b1e5d45f6 to your computer and use it in GitHub Desktop.
Save nabe256/3a7bb15b81282c6e39c2736b1e5d45f6 to your computer and use it in GitHub Desktop.
#!/bin/bash
urls=(\
"https://aws.amazon.com/jp/ 200" \
"https://aws.amazon.com/console/ 200" \
"https://console.aws.amazon.com/ 302" \
)
for (( i = 0; i < ${#urls[@]}; i++ ))
do
case=(${urls[$i]})
url=${case[0]}
expected=${case[1]}
echo "URL: $url Expected: $expected"
result=$(curl -Ss -o /dev/null -w "%{http_code} %{redirect_url}" $url)
set -- $result
if [ "$1" == "$expected" ]; then
s="OK"
else
s="NG"
fi
if [ "$2" != "" ]; then
echo "[$s] Status: $1 Location: $2"
else
echo "[$s] Status: $1"
fi
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment