i have a shell script to curl an url and test if it's ok. On web browser i have no problem, i have the content i'm waiting for.
but after running this shell :
#!/bin/bash
URL="www.mypersonalURL.com/"
STATUS=$(curl -s -o /dev/null -w "%{http_code}\n" $URL)
if [ $STATUS == 200 ] ; then
echo "$URL is up, returned $STATUS"
else
echo "$URL is not up, returned $STATUS"
fi
i always get a 308 code, what to do to make the redirection go forward and land on a 200 ?
CodePudding user response:
You are not following the redirect in your curl statement. Add -L
to your curl.
URL="www.mypersonalURL.com/"
STATUS=$(curl -L -s -o /dev/null -w "%{http_code}\n" $URL)