How to make curl be curt, but still output error messages such as timeout

published May 06, 2018 11:15   by admin ( last modified May 06, 2018 03:04 )

I needed to continuously check if a service was working, both checking for the response code from it and checking whether it replied at all. I used the shell "watch" command together with curl.

I silenced curl with "-s" in order to not see the progress bar, but still get the result. However that also silenced error messages. It turns out you need "-S" (capital S) to unsilence error messages.

watch curl -s -S http://foo.example.com

Incidentally, "http://example.com" returns a web page on my machine. Hence the "foo" subdomain.

-s Silent or quiet mode. Don't show progress meter or error messages. Makes Curl mute. -S When used with -s it makes curl show an error message if it fails.

Read more: Link - Making curl send errors to stderr and everything else to stdout - Stack Overflow