티스토리 뷰

공부

[Sh] curl request & response (status code)

seunggabi 승가비 2021. 5. 25. 22:23
#!/bin/bash

status_code=$(curl --write-out %{http_code} --silent --output /dev/null www.bbc.co.uk/news)

if [[ "$status_code" -ne 200 ]] ; then
  exit 1
else
  exit 0
fi

https://stackoverflow.com/questions/2220301/how-to-evaluate-http-response-codes-from-bash-shell-script

 

How to evaluate http response codes from bash/shell script?

I have the feeling that I'm missing the obvious, but have not succeeded with man [curl|wget] or google ("http" makes such a bad search term). I'm looking for a quick&dirty fix to one of our

stackoverflow.com

 

댓글
댓글쓰기 폼