curl / Mailing Lists / curl-users / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: curl with bash and proper error handling

From: Rainer Canavan via curl-users <curl-users_at_cool.haxx.se>
Date: Fri, 6 Nov 2020 13:26:39 +0100

[...]
> I just want to get the content of a http request and the status code.
> The content to either use it directly or to make it visible in a way
> that I'm able to see the issue when my curl command fails inside my
> script.

you can use -o to write the response body to a file or -w with
%{stderr} and %{http_code} to write the http status code to stderr
instead of stdout.

> 3. Could curl return the first number as a sub status code? Like 1,2,3,4 or 5?

use sed or similar tools to extract just the first digit. It doesn't
make sense to build something like this into curl if other tools can
do the job much better already.

rainer
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-11-06