cURL / Mailing Lists / curl-users / Single Mail


Re: Exit Codes?

From: Dan Fandrich <>
Date: Wed, 24 May 2006 14:08:46 -0700

On Wed, May 24, 2006 at 03:45:48PM -0500, Art Norman wrote:
> I need to test the curl "exit code" without using the verbose (-v) option. Any
> suggestions?
> The only time I have seen the numerical "exit code" is when I use the verbose
> option. However I don't want curl to output to the screen in production for a
> non-technical user (curl script runs in background for credit card
> authorization app). The text for any error is in the trace file, but I don't
> see the numerical exit code value in the trace file. I need to capture and
> test the exit code in my script (UNIX) so that the application can provide a
> user friendly message to a non-technical user.

curl sets its exit code to the error number. In, bash, you can get access
to it like this:

$ curl dict://localhost/
curl: (7) couldn't connect to host
$ echo "Curl exited due to error $?"
Curl exited due to error 7

A case statement can translate those error numbers to text messages (any of
75 of them!)

>>> Dan

--              The web change of address service
          Let webmasters know that your web site has moved
Received on 2006-05-24