Re: [IDEA] --write-out print body on http error code
Daniel Stenberg via curl-users <[email protected]>
| Newsgroups | gmane.comp.web.curl.general |
|---|---|
| Message-ID | <[email protected]> |
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