Function for bash_profile to test your websites

This is a simple, adjustable function you can put in your bash_profile to test if your websites give the right http status:

function test {
	declare -a array=(
		"https://www.puddinq.com" 
		"https://www.puddinq.nl" 
		"https://puddinq.mobi"
		"https://www.winkel-centrum.nl"
		"https://lekker-kontje.nl"
		)
	for i in "${array[@]}"
	do
		echo -ne "$i "; curl -Is "$i" | head -1
	done
}

The rusult will be as simple as:

https://www.puddinq.com HTTP/2 200
https://www.puddinq.nl HTTP/2 200
https://puddinq.mobi HTTP/2 200
https://www.winkel-centrum.nl HTTP/2 200
https://lekker-kontje.nl HTTP/2 200

 

And even better, the script below gives a green output for 200 red for the rest

function test {
 declare -a array=(
 "https://www.puddinq.com" 
 "https://www.puddinq.nl" 
 "https://puddinq.mobi"
 "https://www.winkel-centrum.nl"
 "https://lekker-kontje.nl"
 "http://admiraliteit.nl/"
 "https://www.rlsd.nl/"
 )
 
bold=$(tput bold)
green=$(tput setaf 2)
red=$(tput setaf 1)
reset=$(tput sgr0)

 for i in "${array[@]}"
 do
 echo -ne "${bold}$i${reset} ";
 
 
status_code=$(curl -Is "$i" --connect-timeout 5 | head -1)
 
if [[ "$status_code" == *"200"* ]] ; then
  echo  "${green}$status_code${reset} ";
else
  echo  "${red}$i${reset} ";
fi
 
 done
}