cURL / Mailing Lists / curl-users / Single Mail


Re: return code of curl -O BLAH

From: Linus Nielsen Feltzing <>
Date: Sun, 06 Jun 2004 10:53:37 +0200

John F. Koenig wrote:
> if BLAH does not exist... why does curl return a successful operation?
> I saw the post (appended below) which addresses a similar issue.
> Maybe I am not seeing the light on the policy decision involved.
> In a script, should one verify the existence of a particular URL,
> in effect testing if it exists, before invoking curl?

If you want curl to fail on server errors, like non-existing URL's, use
the --fail switch:

Snippet from the man page:


(HTTP) Fail silently (no output at all) on server errors. This is mostly
done like this to better enable scripts etc to better deal with failed
attempts. In normal cases when a HTTP server fails to deliver a
document, it returns a HTML document stating so (which often also
describes why and more). This flag will prevent curl from outputting
that and fail silently instead.

If this option is used twice, the second will again disable silent failure.

Received on 2004-06-06