NAME. curl - transfer a URL SYNOPSIS. curl [options] DESCRIPTION. curl is a tool to transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS. Join the Stack Overflow community to: Ask programming questions Answer and help your peers Get recognized for your expertise. Curl examples curl http:// Fetch the file index.htm from www.computerhope.com using the HTTP protocol, and display it to standard output. This is essentially the same as 'viewing the source' of. 1. Philosophy 1.1 What is cURL? cURL is the name of the project. The name is a play on 'Client for URLs', originally with URL spelled in uppercase to make it obvious it deals with URLs. The fact it can also be pronounced 'see.
Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta.
Linux and UNIX curl command help and examples. About curlcurl syntaxcurl examples. Related commands. Linux and Unix main page. About curlcurl is a tool to transfer data from or to a server, using one of the supported protocols (HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP or FILE). The command is designed to work without user interaction.
When the METHOD argument is omitted from the command, HTTPie defaults to either GET (with no request data) or POST (with request data). Request URL. The only information HTTPie needs to perform a request is a URL. The default.
FTP uploading, HTTP posting, SSL connections, cookies, file transfer resume, Metalink, and many other features, listed below. Progress Metercurl normally displays a progress meter during operations, indicating the amount of transferred data, transfer speeds and estimated time left, etc. If you want a progress meter for HTTP POST or PUT requests, you need to redirect the response output to a file, using shell redirect (> ), - o[file] or similar. It is not the same case for FTP upload as that operation does not spit out any response data to the terminal. If you prefer a progress "bar" instead of the regular meter, - # is your friend. About the URLThe URLsyntax is protocol- dependent.
You'll find a detailed description in RFC 3. You can specify multiple URLs or parts of URLs by writing part sets within braces as in: http: //site.{one,two,three}. Nested sequences are not supported, but you can use several ones next to each other: http: //any. You can specify any amount of URLs on the command line.
They will be fetched in a sequential manner in the specified order. You can specify a step counter for the ranges to get every Nth number or letter: http: //www. 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. URL. It is not trying to validate it as a syntactically correct URL by any means but is instead very liberal with what it accepts. 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.
URL..]Options- a, - -append(FTP/SFTP) 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. Note that this option is ignored by some SSH servers, including Open. SSH.- A, - -user- agent< agent string> (HTTP) Specify the User- Agentstring to send to the HTTP server. Some CGIs fail if the agent string is not set to "Mozilla/4. To encode blanks in the string, surround the string with single quote marks. This value can also be set with the - H/- -header option.
If this option is set more than once, the last one will be the one that's used.- -anyauth(HTTP) Tells curl to figure out authentication method by itself, and use the most secure method the remote site claims it supports. This is done by first making a request and checking the response- headers, thus possibly inducing an network round- trip. This is used instead of setting a specific authentication method, which you can do with - -basic, - -digest, - -ntlm, and - -negotiate. 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.- b, - -cookie< name=data> (HTTP) Pass the data to the HTTP server as a cookie. It is expected to be 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 '=' (equals) character 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 - -location option.
The file format of the file to read cookies from should be plain HTTP headers or the Netscape/Mozilla cookie file format. NOTE: the file specified with - b/- -cookie is only used as input. No cookies will be stored in the file. To store cookies, use the - c/- -cookie- jar option, or you can save the HTTP headers to a file using - D/- -dump- header. If this option is set more than once, the last occurrence will be the option that's used.- B, - -use- ascii(FTP/LDAP) Enable ASCII transfer. 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 win.
If this option is used twice, the second one will disable ASCII usage.- -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 - -ntlm, - -digest and - -negotiate).- -ciphers< list of ciphers> (SSL) Specifies which ciphers to use in the connection.
The ciphers listed must be valid. You can read up on SSL cipher list details at openssl. NSS ciphers are done differently than Open. SSL and Gnu. TLS. The full list of NSS ciphers is in the NSSCipher. Suite entry at this URL: http: //git. Directives. If this option is used several times, the last one will override the others.- -compressed(HTTP) Request a compressed response using one of the algorithmscurl supports, and return the uncompressed document.
If this option is used and the server sends an unsupported encoding, Curl will report an error.- -connect- timeout< seconds> Maximum time in seconds that the connection to the server may take. This only limits the connection phase; once curl has connected this option no longer applies. Since 7. 3. 2. 0, this option accepts decimal values, but the actual timeout will decrease in accuracy as the specified timeout increases in decimal precision. See also the - m/- -max- time option.
If this option is used several times, the last one will be used.- c, - -cookie- jar< file name> (HTTP) 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 file format.
If you set the file name to a single dash ("- "), the cookies will be written to stdout. This command line option will activate the cookie engine that makes curl record and use cookies. Another way to activate it is to use the - b/- -cookie option. NOTE: If the cookie jar can't be created or written to, the whole curl operation won't fail or even report an error.
If - v is specified a warning will be displayed, but that is the only visible feedback you get about this possibly fatal situation. If this option is used several times, the last specified file name will be used.- 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. If this option is used several times, the last one will be used.- -create- dirs. When used in conjunction with the - o option, curl will create the necessary local directoryhierarchy as needed.
This option creates the dirs mentioned with the - o option, nothing else. If the - o file name uses no directory or if the directories it mentions already exist, no directories will be created. To create remote directories when using FTP or SFTP, try - -ftp- create- dirs.- -crlf(FTP) Convert LF to CRLF in upload.
Useful for MVS (OS/3. HTTPS/FTPS) Provide a file using PEM format with a Certificate Revocation List that may specify peer certificates that are to be considered revoked. If this option is used several times, the last one will be used.(Added in 7.
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 an 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 - F/- -form. If this option is used more than once on the same command line, the data pieces specified will be merged together with a separating "& " character. Thus, using '- d name=daniel - d skill=lousy' would generate a POST chunk that looks like 'name=daniel& skill=lousy'.
If you start the data with the "@" character, the rest should be a file name to read the data from, or "- " (dash) 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 "- -data @foo- bar".- d/- -data is the same as - -data- ascii. To post data purely binary, you should instead use the - -data- binary option. To URL- encode the value of a form field you may use - -data- urlencode. If this option is used several times, the ones following the first will append data.- -data- ascii< data> (HTTP) This is an alias for the - d/- -data option. If this option is used several times, the ones following the first will append data.- -data- binary< data> (HTTP) This posts data exactly as specified with no extra processing whatsoever.
If you start the data with the character @, the rest should be a filename. Data is posted in a similar manner as - -data- ascii does, except that newlines are preserved and conversions are never done.