cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-users Mailing List Archives

Re: Exit Codes?

From: Dan Fandrich <dan_at_coneharvesters.com>
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

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2006-05-24

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET