Skip to content
Snippets Groups Projects
curl.1 56.1 KiB
Newer Older
.\" **************************************************************************
.\" *                                  _   _ ____  _
.\" *  Project                     ___| | | |  _ \| |
.\" *                             / __| | | | |_) | |
.\" *                            | (__| |_| |  _ <| |___
.\" *                             \___|\___/|_| \_\_____|
.\" *
.\" * Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" *
.\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms
.\" * are also available at http://curl.haxx.se/docs/copyright.html.
.\" *
.\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
.\" * copies of the Software, and permit persons to whom the Software is
.\" * furnished to do so, under the terms of the COPYING file.
.\" *
.\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
.\" * KIND, either express or implied.
.\" *
.\" * $Id$
.\" **************************************************************************
Daniel Stenberg's avatar
Daniel Stenberg committed
.TH curl 1 "4 Sep 2005" "Curl 7.14.2" "Curl Manual"
Daniel Stenberg's avatar
Daniel Stenberg committed
curl \- transfer a URL
.SH SYNOPSIS
.B curl [options]
.I [URL...]
.SH DESCRIPTION
.B curl
is a tool to transfer data from or to a server, using one of the supported
protocols (HTTP, HTTPS, FTP, FTPS, TFTP, GOPHER, DICT, TELNET, LDAP or
FILE). The command is designed to work without user interaction.

curl offers a busload of useful tricks like proxy support, user
authentication, ftp upload, HTTP post, SSL (https:) connections, cookies, file
transfer resume and more. As you will see below, the amount of features will
make your head spin!

curl is powered by libcurl for all transfer-related features. See
.BR libcurl (3)
for details.
.SH URL
The URL syntax is protocol dependent. You'll find a detailed description in
RFC 2396.

You can specify multiple URLs or parts of URLs by writing part sets within
braces as in:

 http://site.{one,two,three}.com

or you can get sequences of alphanumeric series by using [] as in:

 ftp://ftp.numericals.com/file[1-100].txt
 ftp://ftp.numericals.com/file[001-100].txt    (with leading zeros)
 ftp://ftp.letters.com/file[a-z].txt

No nesting of the sequences is supported at the moment, but you can use
several ones next to each other:
 http://any.org/archive[1996-1999]/vol[1-4]/part{a,b,c}.html
You can specify any amount of URLs on the command line. They will be fetched
in a sequential manner in the specified order.
If you specify URL without protocol:// prefix, curl will attempt to guess what
protocol you might want. It will then default to HTTP but try other protocols
based on often-used host name prefixes. For example, for host names starting
with "ftp." curl will assume you want to speak FTP.

Curl will attempt to re-use connections for multiple file transfers, so that
getting many files from the same server will not do multiple connects /
handshakes. This improves speed. Of course this is only done on files
specified on a single command line and cannot be used between separate curl
invokes.
.SH OPTIONS
.IP "-a/--append"
(FTP) When used in an FTP upload, this will tell curl to append to the target
file instead of overwriting it. If the file doesn't exist, it will be created.

If this option is used twice, the second one will disable append mode again.
.IP "-A/--user-agent <agent string>"
(HTTP) Specify the User-Agent string to send to the HTTP server. Some badly
done CGIs fail if its not set to "Mozilla/4.0".  To encode blanks in the
string, surround the string with single quote marks.  This can also be set
with the \fI-H/--header\fP option of course.
Daniel Stenberg's avatar
Daniel Stenberg committed
If this option is set more than once, the last one will be the one that's
.IP "--anyauth"
(HTTP) Tells curl to figure out authentication method by itself, and use the
most secure one the remote site claims it supports. This is done by first
doing a request and checking the response-headers, thus inducing an extra
network round-trip. This is used instead of setting a specific authentication
Daniel Stenberg's avatar
Daniel Stenberg committed
method, which you can do with \fI--basic\fP, \fI--digest\fP, \fI--ntlm\fP, and
\fI--negotiate\fP. (Added in 7.10.6)

Note that using --anyauth is not recommended if you do uploads from stdin,
since it may require data to be sent twice and then the client must be able to
rewind. If the need should arise when uploading from stdin, the upload
operation will fail.

If this option is used several times, the following occurrences make no
difference.
.IP "-b/--cookie <name=data>"
(HTTP)
Pass the data to the HTTP server as a cookie. It is supposedly the
data previously received from the server in a "Set-Cookie:" line.
The data should be in the format "NAME1=VALUE1; NAME2=VALUE2".

If no '=' letter is used in the line, it is treated as a filename to use to
read previously stored cookie lines from, which should be used in this session
if they match. Using this method also activates the "cookie parser" which will
make curl record incoming cookies too, which may be handy if you're using this
in combination with the \fI-L/--location\fP option. The file format of the
file to read cookies from should be plain HTTP headers or the Netscape/Mozilla
cookie file format.
\fBNOTE\fP that the file specified with \fI-b/--cookie\fP is only used as
input. No cookies will be stored in the file. To store cookies, use the
\fI-c/--cookie-jar\fP option or you could even save the HTTP headers to a file
using \fI-D/--dump-header\fP!
Daniel Stenberg's avatar
Daniel Stenberg committed
If this option is set more than once, the last one will be the one that's
.IP "-B/--use-ascii"
Enable ASCII transfer when using FTP or LDAP. For FTP, this can also be
enforced by using an URL that ends with ";type=A". This option causes data
sent to stdout to be in text mode for win32 systems.

If this option is used twice, the second one will disable ASCII usage.
.IP "--basic"
(HTTP) Tells curl to use HTTP Basic authentication. This is the default and
this option is usually pointless, unless you use it to override a previously
set option that sets a different authentication method (such as \fI--ntlm\fP,
\fI--digest\fP and \fI--negotiate\fP). (Added in 7.10.6)

If this option is used several times, the following occurrences make no
difference.
Daniel Stenberg's avatar
Daniel Stenberg committed
.IP "--ciphers <list of ciphers>"
(SSL) Specifies which ciphers to use in the connection. The list of ciphers
must be using valid ciphers. Read up on SSL cipher list details on this URL:
\fIhttp://www.openssl.org/docs/apps/ciphers.html\fP
Daniel Stenberg's avatar
Daniel Stenberg committed

If this option is used several times, the last one will override the others.
.IP "--compressed"
(HTTP) Request a compressed response using one of the algorithms libcurl
supports, and return the uncompressed document.  If this option is used and
the server sends an unsupported encoding, Curl will report an error.

If this option is used several times, each occurrence will toggle it on/off.
.IP "--connect-timeout <seconds>"
Maximum time in seconds that you allow the connection to the server to take.
This only limits the connection phase, once curl has connected this option is
Daniel Stenberg's avatar
Daniel Stenberg committed
of no more use. See also the \fI-m/--max-time\fP option.
Daniel Stenberg's avatar
Daniel Stenberg committed
If this option is used several times, the last one will be used.
.IP "-c/--cookie-jar <file name>"
Specify to which file you want curl to write all cookies after a completed
operation. Curl writes all cookies previously read from a specified file as
well as all cookies received from remote server(s). If no cookies are known,
no file will be written. The file will be written using the Netscape cookie
Daniel Stenberg's avatar
Daniel Stenberg committed
file format. If you set the file name to a single dash, "-", the cookies will
be written to stdout.
.B NOTE
If the cookie jar can't be created or written to, the whole curl operation
won't fail or even report an error clearly. Using -v will get a warning
displayed, but that is the only visible feedback you get about this possibly
lethal situation.

If this option is used several times, the last specified file name will be
used.
.IP "-C/--continue-at <offset>"
Continue/Resume a previous file transfer at the given offset. The given offset
is the exact number of bytes that will be skipped counted from the beginning
of the source file before it is transferred to the destination.  If used with
uploads, the ftp server command SIZE will not be used by curl.

Use "-C -" to tell curl to automatically find out where/how to resume the
transfer. It then uses the given output/input files to figure that out.
Daniel Stenberg's avatar
Daniel Stenberg committed
If this option is used several times, the last one will be used.
Daniel Stenberg's avatar
Daniel Stenberg committed
.IP "--create-dirs"
When used in conjunction with the -o option, curl will create the necessary
local directory hierarchy as needed. This option creates the dirs mentioned
with the -o option, nothing else. If the -o file name uses no dir or if the
dirs it mentions already exist, no dir will be created.

To create remote directories when using FTP, try \fI--ftp-create-dirs\fP.
.IP "--crlf"
(FTP) Convert LF to CRLF in upload. Useful for MVS (OS/390).

If this option is used twice, the second will again disable crlf converting.
.IP "-d/--data <data>"
(HTTP) Sends the specified data in a POST request to the HTTP server, in a way
that can emulate as if a user has filled in a HTML form and pressed the submit
button. Note that the data is sent exactly as specified with no extra
processing (with all newlines cut off).  The data is expected to be
\&"url-encoded". This will cause curl to pass the data to the server using the
content-type application/x-www-form-urlencoded. Compare to \fI-F/--form\fP. If
this option is used more than once on the same command line, the data pieces
specified will be merged together with a separating &-letter. Thus, using '-d
name=daniel -d skill=lousy' would generate a post chunk that looks like

If you start the data with the letter @, the rest should be a file name to
read the data from, or - if you want curl to read the data from stdin.  The
contents of the file must already be url-encoded. Multiple files can also be
specified. Posting data from a file named 'foobar' would thus be done with
\fI--data\fP @foobar".
To post data purely binary, you should instead use the \fI--data-binary\fP
option.
\fI-d/--data\fP is the same as \fI--data-ascii\fP.
Daniel Stenberg's avatar
Daniel Stenberg committed
If this option is used several times, the ones following the first will
Daniel Stenberg's avatar
Daniel Stenberg committed
.IP "--data-ascii <data>"
(HTTP) This is an alias for the \fI-d/--data\fP option.
Daniel Stenberg's avatar
Daniel Stenberg committed
If this option is used several times, the ones following the first will
Daniel Stenberg's avatar
Daniel Stenberg committed
.IP "--data-binary <data>"
(HTTP) This posts data in a similar manner as \fI--data-ascii\fP does,
although when using this option the entire context of the posted data is kept
as-is. If you want to post a binary file without the strip-newlines feature of
the \fI--data-ascii\fP option, this is for you.
Daniel Stenberg's avatar
Daniel Stenberg committed
If this option is used several times, the ones following the first will
.IP "--digest"
(HTTP) Enables HTTP Digest authentication. This is a authentication that
prevents the password from being sent over the wire in clear text. Use this in
combination with the normal \fI-u/--user\fP option to set user name and
password. See also \fI--ntlm\fP, \fI--negotiate\fP and \fI--anyauth\fP for
related options. (Added in curl 7.10.6)

If this option is used several times, the following occurrences make no
difference.
.IP "--disable-eprt"
(FTP) Tell curl to disable the use of the EPRT and LPRT commands when doing
active FTP transfers. Curl will normally always first attempt to use EPRT,
then LPRT before using PORT, but with this option, it will use PORT right
away. EPRT and LPRT are extensions to the original FTP protocol, may not work
on all servers but enable more functionality in a better way than the
traditional PORT command. (Added in 7.10.5)
If this option is used several times, each occurrence will toggle this on/off.
Daniel Stenberg's avatar
Daniel Stenberg committed
.IP "--disable-epsv"
(FTP) Tell curl to disable the use of the EPSV command when doing passive FTP
transfers. Curl will normally always first attempt to use EPSV before PASV,
Daniel Stenberg's avatar
Daniel Stenberg committed
but with this option, it will not try using EPSV.

If this option is used several times, each occurrence will toggle this on/off.
.IP "-D/--dump-header <file>"
Write the protocol headers to the specified file.
This option is handy to use when you want to store the headers that a HTTP
site sends to you. Cookies from the headers could then be read in a second
curl invoke by using the \fI-b/--cookie\fP option! The \fI-c/--cookie-jar\fP
option is however a better way to store cookies.
When used on FTP, the ftp server response lines are considered being "headers"
and thus are saved there.

Daniel Stenberg's avatar
Daniel Stenberg committed
If this option is used several times, the last one will be used.
.IP "-e/--referer <URL>"
(HTTP) Sends the "Referer Page" information to the HTTP server. This can also
be set with the \fI-H/--header\fP flag of course.  When used with
\fI-L/--location\fP you can append ";auto" to the referer URL to make curl
automatically set the previous URL when it follows a Location: header. The
\&";auto" string can be used alone, even if you don't set an initial referer.
Daniel Stenberg's avatar
Daniel Stenberg committed
If this option is used several times, the last one will be used.
.IP "--engine <name>"
Select the OpenSSL crypto engine to use for cipher
operations. Use \fI--engine list\fP to print a list of build-time supported
engines. Note that not all (or none) of the engines may be available at
run-time.
.IP "--environment"
(RISC OS ONLY) Sets a range of environment variables, using the names the -w
option supports, to easier allow extraction of useful information after having
run curl.

If this option is used several times, each occurrence will toggle this on/off.
.IP "--egd-file <file>"
(HTTPS) Specify the path name to the Entropy Gathering Daemon socket. The
socket is used to seed the random engine for SSL connections. See also the
\fI--random-file\fP option.
.IP "-E/--cert <certificate[:password]>"
(HTTPS)
Tells curl to use the specified certificate file when getting a file
with HTTPS. The certificate must be in PEM format.
If the optional password isn't specified, it will be queried for on
the terminal. Note that this certificate is the private key and the private
certificate concatenated!
If this option is used several times, the last one will be used.
.IP "--cert-type <type>"
(SSL) Tells curl what certificate type the provided certificate is in. PEM,
DER and ENG are recognized types.

Daniel Stenberg's avatar
Daniel Stenberg committed
If this option is used several times, the last one will be used.
Daniel Stenberg's avatar
Daniel Stenberg committed
.IP "--cacert <CA certificate>"
(HTTPS) Tells curl to use the specified certificate file to verify the
peer. The file may contain multiple CA certificates. The certificate(s) must
be in PEM format.

curl recognizes the environment variable named 'CURL_CA_BUNDLE' if that is
set, and uses the given path as a path to a CA cert bundle. This option
overrides that variable.

The windows version of curl will automatically look for a CA certs file named
\'curl-ca-bundle.crt\', either in the same directory as curl.exe, or in the
Current Working Directory, or in any folder along your PATH.

If this option is used several times, the last one will be used.
.IP "--capath <CA certificate directory>"
(HTTPS) Tells curl to use the specified certificate directory to verify the
peer. The certificates must be in PEM format, and the directory must have been
processed using the c_rehash utility supplied with openssl. Using
\fI--capath\fP can allow curl to make https connections much more efficiently
than using \fI--cacert\fP if the \fI--cacert\fP file contains many CA
certificates.
Daniel Stenberg's avatar
Daniel Stenberg committed
If this option is used several times, the last one will be used.
.IP "-f/--fail"
(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.
Daniel Stenberg's avatar
Daniel Stenberg committed
If this option is used twice, the second will again disable silent failure.
.IP "--ftp-account [data]"
(FTP) When an FTP server asks for "account data" after user name and password
has been provided, this data is sent off using the ACCT command. (Added in
7.13.0)

If this option is used twice, the second will override the previous use.
Daniel Stenberg's avatar
Daniel Stenberg committed
.IP "--ftp-create-dirs"
(FTP) When an FTP URL/operation uses a path that doesn't currently exist on
the server, the standard behavior of curl is to fail. Using this option, curl
will instead attempt to create missing directories. (Added in 7.10.7)
Daniel Stenberg's avatar
Daniel Stenberg committed

If this option is used twice, the second will again disable silent failure.
.IP "--ftp-pasv"
(FTP) Use PASV when transferring. PASV is the internal default behavior, but
using this option can be used to override a previous --ftp-port option. (Added
If this option is used twice, the second will again disable silent failure.
.IP "--ftp-skip-pasv-ip"
(FTP) Tell curl to not use the IP address the server suggests in its response
to curl's PASV command when curl connects the data connection. Instead curl
will re-use the same IP address it already uses for the control
Daniel Stenberg's avatar
Daniel Stenberg committed
connection. (Added in 7.14.2)

This option has no effect if PORT, EPRT or EPSV is used instead of PASV.

If this option is used twice, the second will again disable silent failure.
.IP "--ftp-ssl"
(FTP) Make the FTP connection switch to use SSL/TLS. (Added in 7.11.0)

If this option is used twice, the second will again disable this.
.IP "-F/--form <name=content>"
(HTTP) This lets curl emulate a filled in form in which a user has pressed the
submit button. This causes curl to POST data using the Content-Type
multipart/form-data according to RFC1867. This enables uploading of binary
files etc. To force the 'content' part to be a file, prefix the file name
with an @ sign. To just get the content part from a file, prefix the file name
with the letter <. The difference between @ and < is then that @ makes a file
get attached in the post as a file upload, while the < makes a text field and
just get the contents for that text field from a file.

Example, to send your password file to the server, where
\&'password' is the name of the form-field to which /etc/passwd will be the
Daniel Stenberg's avatar
Daniel Stenberg committed
\fBcurl\fP -F password=@/etc/passwd www.mypasswords.com
To read the file's content from stdin instead of a file, use - where the file
name should've been. This goes for both @ and < constructs.
You can also tell curl what Content-Type to use by using 'type=', in a manner
similar to:
Daniel Stenberg's avatar
Daniel Stenberg committed

\fBcurl\fP -F "web=@index.html;type=text/html" url.com

or

\fBcurl\fP -F "name=daniel;type=text/foo" url.com

Loading
Loading full blame...