Curl

From Omnia
Revision as of 02:23, 3 April 2024 by Kenneth (talk | contribs) (→‎Return status code only)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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