Reputation: 469
I am calling curl to website, checking what http status code and data if returns.
There are 2 cases:
needed result: CURL exiting with 0 unix status code
needed result: CURL exiting with error status code
For now there is used curl with -f modifier (silent).
curl https://mysite.com/something/deploy_status -f
It works great, because it checks the HTTP status code, and return unix error code (22) when there is any problem. However, I need to get also to get the text data, that is sent with error code.
How can I do that? Assume that I can make only one curl call, writing a script is not possible there.
Upvotes: 0
Views: 1064
Reputation: 39355
This is not possible. Its strictly mentioned in curl's manual page -f Fail silently (no output at all) on HTTP errors (H)
So make another curl call to save the html separately.
curl -o output.html YOUR_URL_GOES_HERE
Or use this one that gets you the http status code along with the html page.
curl -s -w %{http_code} http://www.example.com/test -o output.html
Upvotes: 2