Skip to content

Curl

Basic actions

Get a web site:

curl $WEBSITE_URL

Get only the HTTP code back:

curl --silent -o /dev/null -w "%{http_code}" $WEBSITE_URL

Continusly check the HTTP code:

for (( t=1; ; t++ )); do echo "${t}" && curl --silent -o /dev/null -w "%{http_code}" $WEBSITE_URL && sleep 1 && echo ""; done

Get a web site and specify the host we are reaching from:

curl -H Host:$WEBSITE_DNS $WEBSITE_IP

Follow redirect:

curl -L -O $WEBSITE_URL

List the content of a remote folder:

curl --list-only $WEBSITE_URL

Also fetching the headers:

curl -I $WEBSITE_URL

Binaries actions

Get a binary:

curl -O $BINARY_URL

Get multiple binaries:

 for i in $(curl -s https://releases.hashicorp.com/terraform/ | grep href | sed 's/.href="//' | cut -d ">" -f2 | cut -d "<" -f1 | grep -E terraform* | cut -d "_" -f2); do curl -O https://releases.hashicorp.com/terraform/$i/terraform_"$i"_linux_amd64.zip; done