cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl check for file with TFTP

From: Guenter <lists_at_gknw.net>
Date: Wed, 08 Apr 2009 14:00:36 +0200

Hi,
Dan Fandrich schrieb:
> On Wed, Apr 08, 2009 at 05:01:34AM +0200, Guenter wrote:
>> 1. http does always give me status 0 regardless if I pass a valid or
>> invalid URL while ftp returns non-0 for invalid URLs.
>
> What's an example of such an invalid http URL? I get a return code of
> 6 when I feed it an invalid host.
everything which returns a 404, remove the -o /dev/null and you see:

curl -I http://example.com/ ; echo "Status: $?"
HTTP/1.1 200 OK
Date: Wed, 08 Apr 2009 11:49:56 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Tue, 15 Nov 2005 13:24:10 GMT
ETag: "b80f4-1b6-80bfd280"
Accept-Ranges: bytes
Content-Length: 438
Connection: close
Content-Type: text/html; charset=UTF-8

Status: 0

curl -I http://example.com/x ; echo "Status: $?"
HTTP/1.1 404 Not Found
Date: Wed, 08 Apr 2009 11:50:54 GMT
Server: Apache/2.2.3 (CentOS)
Connection: close
Content-Type: text/html; charset=iso-8859-1

Status: 0

hacki@linux-nt36:~/x> curl -I http://example.ccc/ ; echo "Status: $?"
curl: (6) Couldn't resolve host 'example.ccc'
Status: 6

curl -I ftp://ftp.gnu.org/README ; echo "Status: $?"
Last-Modified: Tue, 20 Feb 2007 16:47:24 GMT
Content-Length: 1765
Accept-ranges: bytes
Status: 0

curl -I ftp://ftp.gnu.org/READM ; echo "Status: $?"
curl: (19) Given file does not exist
Status: 19

>> 2. I would have expected that the -s switch should have been sufficient
>> to supress the header output, but seems not, and therefore the -o
>> /dev/null hack.
>
> The documentation states that "Don't show progress meter or error messages"
> and the header isn't either of those.
yes, true.

Guen.
Received on 2009-04-08