Monday, May 26, 2014

To get http status code from curl call

Buy Moto series phones: Moto E, Moto G, Moto X or Other phones
Buy eBooks from Flipkart

We can use below command to get http response code of a URL from bash script.

status_code=$(curl --write-out "\n%{http_code}\n" --silent --output /dev/null --insecure

silent - to stop progress information in output
output - we are re-directing normal output to null device
write-out - whatever things we needed can be given here. Here we are printing http status code. It will be printed after completion, i.e., after printing all output.
insecure - this allows connections to SSL sites without certs


No comments:

Post a Comment

Latest Posts