Can anyone explain me the below curl command and how it works :
STATUS_CODE=`curl –output /dev/null –silent –head –write-out ‘%{http_code}\n’ $next` # If you want to set a timeout then add –max-time 15, here 15 is 15seconds
You seem to be missing a few double dashes, probably the result of copy and paste:
STATUS_CODE=`curl --output /dev/null --silent --head --write-out ‘%{http_code}\n’ $next`
Assuming that you call this with next
being a url (e.g. in a loop or reading from a file):
--output /dev/null
discards the normal output--silent
suppresses the progress meter--head
fetch header only--write-out '%{http_code}\n'
prints the status codeSo in the end the status of the URL request ends up in STATUS_CODE
(And if you want to set the timeout, then use double dashes too: --max-time
).