Is there a way to follow redirects with command line cURL
curl -L <URL>
curl -i -v -k url
Dump response header
--dump-header headers.txt
http://stackoverflow.com/questions/6136022/script-to-get-the-http-status-code-of-a-list-of-urls
curl -L <URL>
curl -i -v -k url
Dump response header
--dump-header headers.txt
http://stackoverflow.com/questions/6136022/script-to-get-the-http-status-code-of-a-list-of-urls
url has a specific option,
--write-out
, for this:$ curl -o /dev/null --silent --head --write-out '%{http_code}\n' <url>
200
-o /dev/null
throws away the usual output--silent
throws away the progress meter--head
makes a HEAD HTTP request, instead of GET--write-out '%{http_code}\n'
prints the required status code
I haven't tested this on a 500 code, but it works on others like 200, 302 and 404.
response=$(curl --write-out %{http_code} --silent --output /dev/null servername)
http://superuser.com/questions/569092/how-to-split-the-http-error-code-from-the-contents-in-curl