Curl: Difference between revisions

From Omnia
Jump to navigation Jump to search
(Created page with "== Return status code only == curl -s -o /dev/null -w "%{http_code}" google.com curl -s -o /dev/null -I -w "%{http_code}" google.com curl -s -o /dev/null -I -w "%{http_code}\n" google.com ref: <ref>https://superuser.com/questions/272265/getting-curl-to-output-http-status-code</ref> == keywords ==")
 
 
Line 2: Line 2:


  curl -s -o /dev/null -w "%{http_code}" google.com
  curl -s -o /dev/null -w "%{http_code}" google.com
curl -s -o /dev/null -i -w "%{http_code}" google.com


  curl -s -o /dev/null -I -w "%{http_code}" google.com
  curl -s -o /dev/null -I -w "%{http_code}" google.com
Line 8: Line 10:


ref: <ref>https://superuser.com/questions/272265/getting-curl-to-output-http-status-code</ref>
ref: <ref>https://superuser.com/questions/272265/getting-curl-to-output-http-status-code</ref>
== Return fail status code ==
curl --fail http://some-url.com
echo $?
-f, --fail (HTTP) Fail silently (no output at all) on server errors


== keywords ==
== keywords ==

Latest revision as of 02:23, 3 April 2024

Return status code only

curl -s -o /dev/null -w "%{http_code}" google.com
curl -s -o /dev/null -i -w "%{http_code}" google.com
curl -s -o /dev/null -I -w "%{http_code}" google.com
curl -s -o /dev/null -I -w "%{http_code}\n" google.com

ref: [1]

Return fail status code

curl --fail http://some-url.com
echo $?
-f, --fail (HTTP) Fail silently (no output at all) on server errors

keywords