Re: [IDEA] --write-out print body on http error code

Bastian Jesuiter via curl-users <[email protected]>
Newsgroups gmane.comp.web.curl.general
Message-ID <CAL07qPV5Bg_hS5+Wzf1NV-53P9JJZY+RVPSCGof7MOd-EvS31w@mail.gmail.com>
Thought so.
I'll experiment a bit with existing write out and will try to use the bash
wrapper.
Thanks for the bash snippet though.
:)

On Sat, 27 Jul 2024, 23:33 Daniel Stenberg, <[email protected]> wrote:

> On Wed, 24 Jul 2024, Bastian Jesuiter wrote:
>
> > --Fail-with-body will also print the error into the file, but not
> display it
> > in stdout if --out-file (-o) is specified. So the idea is to basically
> only
> > write into file if status code is okay (or similar ) but error into
> stdout
> > when there is one. (So that it may potentially be included into logs)
>
> Saving to a file or stderr depending on the HTTP response code seems like
> a
> very specific use case to me. A little too specific for my taste.
>
> It can probably be accomplished with a 4-line shell script wrapper:
>
> curl --fail-with-body -o save http://example.com
> if test "$?" -eq "22"; then
>    cat save >&2
>    rm save
> fi
>
> --
>
>   / daniel.haxx.se
>   | Commercial curl support up to 24x7 is available!
>   | Private help, bug fixes, support, ports, new features
>   | https://curl.se/support.html
>

-- 
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-users
Etiquette:   https://curl.se/mail/etiquette.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.