MANUAL 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878
  1. LATEST VERSION
  2. You always find news about what's going on as well as the latest versions
  3. from the curl web pages, located at:
  4. http://curl.haxx.se
  5. SIMPLE USAGE
  6. Get the main page from netscape's web-server:
  7. curl http://www.netscape.com/
  8. Get the README file the user's home directory at funet's ftp-server:
  9. curl ftp://ftp.funet.fi/README
  10. Get a web page from a server using port 8000:
  11. curl http://www.weirdserver.com:8000/
  12. Get a list of a directory of an FTP site:
  13. curl ftp://cool.haxx.se/
  14. Get a gopher document from funet's gopher server:
  15. curl gopher://gopher.funet.fi
  16. Get the definition of curl from a dictionary:
  17. curl dict://dict.org/m:curl
  18. Fetch two documents at once:
  19. curl ftp://cool.haxx.se/ http://www.weirdserver.com:8000/
  20. DOWNLOAD TO A FILE
  21. Get a web page and store in a local file:
  22. curl -o thatpage.html http://www.netscape.com/
  23. Get a web page and store in a local file, make the local file get the name
  24. of the remote document (if no file name part is specified in the URL, this
  25. will fail):
  26. curl -O http://www.netscape.com/index.html
  27. Fetch two files and store them with their remote names:
  28. curl -O www.haxx.se/index.html -O curl.haxx.se/download.html
  29. USING PASSWORDS
  30. FTP
  31. To ftp files using name+passwd, include them in the URL like:
  32. curl ftp://name:passwd@machine.domain:port/full/path/to/file
  33. or specify them with the -u flag like
  34. curl -u name:passwd ftp://machine.domain:port/full/path/to/file
  35. HTTP
  36. The HTTP URL doesn't support user and password in the URL string. Curl
  37. does support that anyway to provide a ftp-style interface and thus you can
  38. pick a file like:
  39. curl http://name:passwd@machine.domain/full/path/to/file
  40. or specify user and password separately like in
  41. curl -u name:passwd http://machine.domain/full/path/to/file
  42. NOTE! Since HTTP URLs don't support user and password, you can't use that
  43. style when using Curl via a proxy. You _must_ use the -u style fetch
  44. during such circumstances.
  45. HTTPS
  46. Probably most commonly used with private certificates, as explained below.
  47. GOPHER
  48. Curl features no password support for gopher.
  49. PROXY
  50. Get an ftp file using a proxy named my-proxy that uses port 888:
  51. curl -x my-proxy:888 ftp://ftp.leachsite.com/README
  52. Get a file from a HTTP server that requires user and password, using the
  53. same proxy as above:
  54. curl -u user:passwd -x my-proxy:888 http://www.get.this/
  55. Some proxies require special authentication. Specify by using -U as above:
  56. curl -U user:passwd -x my-proxy:888 http://www.get.this/
  57. See also the environment variables Curl support that offer further proxy
  58. control.
  59. RANGES
  60. With HTTP 1.1 byte-ranges were introduced. Using this, a client can request
  61. to get only one or more subparts of a specified document. Curl supports
  62. this with the -r flag.
  63. Get the first 100 bytes of a document:
  64. curl -r 0-99 http://www.get.this/
  65. Get the last 500 bytes of a document:
  66. curl -r -500 http://www.get.this/
  67. Curl also supports simple ranges for FTP files as well. Then you can only
  68. specify start and stop position.
  69. Get the first 100 bytes of a document using FTP:
  70. curl -r 0-99 ftp://www.get.this/README
  71. UPLOADING
  72. FTP
  73. Upload all data on stdin to a specified ftp site:
  74. curl -T - ftp://ftp.upload.com/myfile
  75. Upload data from a specified file, login with user and password:
  76. curl -T uploadfile -u user:passwd ftp://ftp.upload.com/myfile
  77. Upload a local file to the remote site, and use the local file name remote
  78. too:
  79. curl -T uploadfile -u user:passwd ftp://ftp.upload.com/
  80. Upload a local file to get appended to the remote file using ftp:
  81. curl -T localfile -a ftp://ftp.upload.com/remotefile
  82. Curl also supports ftp upload through a proxy, but only if the proxy is
  83. configured to allow that kind of tunneling. If it does, you can run curl in
  84. a fashion similar to:
  85. curl --proxytunnel -x proxy:port -T localfile ftp.upload.com
  86. HTTP
  87. Upload all data on stdin to a specified http site:
  88. curl -T - http://www.upload.com/myfile
  89. Note that the http server must've been configured to accept PUT before this
  90. can be done successfully.
  91. For other ways to do http data upload, see the POST section below.
  92. VERBOSE / DEBUG
  93. If curl fails where it isn't supposed to, if the servers don't let you in,
  94. if you can't understand the responses: use the -v flag to get verbose
  95. fetching. Curl will output lots of info and what it sends and receives in
  96. order to let the user see all client-server interaction (but it won't show
  97. you the actual data).
  98. curl -v ftp://ftp.upload.com/
  99. To get even more details and information on what curl does, try using the
  100. --trace or --trace-ascii options with a given file name to log to, like
  101. this:
  102. curl --trace trace.txt www.haxx.se
  103. DETAILED INFORMATION
  104. Different protocols provide different ways of getting detailed information
  105. about specific files/documents. To get curl to show detailed information
  106. about a single file, you should use -I/--head option. It displays all
  107. available info on a single file for HTTP and FTP. The HTTP information is a
  108. lot more extensive.
  109. For HTTP, you can get the header information (the same as -I would show)
  110. shown before the data by using -i/--include. Curl understands the
  111. -D/--dump-header option when getting files from both FTP and HTTP, and it
  112. will then store the headers in the specified file.
  113. Store the HTTP headers in a separate file (headers.txt in the example):
  114. curl --dump-header headers.txt curl.haxx.se
  115. Note that headers stored in a separate file can be very useful at a later
  116. time if you want curl to use cookies sent by the server. More about that in
  117. the cookies section.
  118. POST (HTTP)
  119. It's easy to post data using curl. This is done using the -d <data>
  120. option. The post data must be urlencoded.
  121. Post a simple "name" and "phone" guestbook.
  122. curl -d "name=Rafael%20Sagula&phone=3320780" \
  123. http://www.where.com/guest.cgi
  124. How to post a form with curl, lesson #1:
  125. Dig out all the <input> tags in the form that you want to fill in. (There's
  126. a perl program called formfind.pl on the curl site that helps with this).
  127. If there's a "normal" post, you use -d to post. -d takes a full "post
  128. string", which is in the format
  129. <variable1>=<data1>&<variable2>=<data2>&...
  130. The 'variable' names are the names set with "name=" in the <input> tags, and
  131. the data is the contents you want to fill in for the inputs. The data *must*
  132. be properly URL encoded. That means you replace space with + and that you
  133. write weird letters with %XX where XX is the hexadecimal representation of
  134. the letter's ASCII code.
  135. Example:
  136. (page located at http://www.formpost.com/getthis/
  137. <form action="post.cgi" method="post">
  138. <input name=user size=10>
  139. <input name=pass type=password size=10>
  140. <input name=id type=hidden value="blablabla">
  141. <input name=ding value="submit">
  142. </form>
  143. We want to enter user 'foobar' with password '12345'.
  144. To post to this, you enter a curl command line like:
  145. curl -d "user=foobar&pass=12345&id=blablabla&ding=submit" (continues)
  146. http://www.formpost.com/getthis/post.cgi
  147. While -d uses the application/x-www-form-urlencoded mime-type, generally
  148. understood by CGI's and similar, curl also supports the more capable
  149. multipart/form-data type. This latter type supports things like file upload.
  150. -F accepts parameters like -F "name=contents". If you want the contents to
  151. be read from a file, use <@filename> as contents. When specifying a file,
  152. you can also specify the file content type by appending ';type=<mime type>'
  153. to the file name. You can also post the contents of several files in one
  154. field. For example, the field name 'coolfiles' is used to send three files,
  155. with different content types using the following syntax:
  156. curl -F "coolfiles=@fil1.gif;type=image/gif,fil2.txt,fil3.html" \
  157. http://www.post.com/postit.cgi
  158. If the content-type is not specified, curl will try to guess from the file
  159. extension (it only knows a few), or use the previously specified type (from
  160. an earlier file if several files are specified in a list) or else it will
  161. using the default type 'text/plain'.
  162. Emulate a fill-in form with -F. Let's say you fill in three fields in a
  163. form. One field is a file name which to post, one field is your name and one
  164. field is a file description. We want to post the file we have written named
  165. "cooltext.txt". To let curl do the posting of this data instead of your
  166. favourite browser, you have to read the HTML source of the form page and
  167. find the names of the input fields. In our example, the input field names
  168. are 'file', 'yourname' and 'filedescription'.
  169. curl -F "file=@cooltext.txt" -F "yourname=Daniel" \
  170. -F "filedescription=Cool text file with cool text inside" \
  171. http://www.post.com/postit.cgi
  172. To send two files in one post you can do it in two ways:
  173. 1. Send multiple files in a single "field" with a single field name:
  174. curl -F "pictures=@dog.gif,cat.gif"
  175. 2. Send two fields with two field names:
  176. curl -F "docpicture=@dog.gif" -F "catpicture=@cat.gif"
  177. REFERRER
  178. A HTTP request has the option to include information about which address
  179. that referred to actual page. Curl allows you to specify the
  180. referrer to be used on the command line. It is especially useful to
  181. fool or trick stupid servers or CGI scripts that rely on that information
  182. being available or contain certain data.
  183. curl -e www.coolsite.com http://www.showme.com/
  184. NOTE: The referer field is defined in the HTTP spec to be a full URL.
  185. USER AGENT
  186. A HTTP request has the option to include information about the browser
  187. that generated the request. Curl allows it to be specified on the command
  188. line. It is especially useful to fool or trick stupid servers or CGI
  189. scripts that only accept certain browsers.
  190. Example:
  191. curl -A 'Mozilla/3.0 (Win95; I)' http://www.nationsbank.com/
  192. Other common strings:
  193. 'Mozilla/3.0 (Win95; I)' Netscape Version 3 for Windows 95
  194. 'Mozilla/3.04 (Win95; U)' Netscape Version 3 for Windows 95
  195. 'Mozilla/2.02 (OS/2; U)' Netscape Version 2 for OS/2
  196. 'Mozilla/4.04 [en] (X11; U; AIX 4.2; Nav)' NS for AIX
  197. 'Mozilla/4.05 [en] (X11; U; Linux 2.0.32 i586)' NS for Linux
  198. Note that Internet Explorer tries hard to be compatible in every way:
  199. 'Mozilla/4.0 (compatible; MSIE 4.01; Windows 95)' MSIE for W95
  200. Mozilla is not the only possible User-Agent name:
  201. 'Konqueror/1.0' KDE File Manager desktop client
  202. 'Lynx/2.7.1 libwww-FM/2.14' Lynx command line browser
  203. COOKIES
  204. Cookies are generally used by web servers to keep state information at the
  205. client's side. The server sets cookies by sending a response line in the
  206. headers that looks like 'Set-Cookie: <data>' where the data part then
  207. typically contains a set of NAME=VALUE pairs (separated by semicolons ';'
  208. like "NAME1=VALUE1; NAME2=VALUE2;"). The server can also specify for what
  209. path the "cookie" should be used for (by specifying "path=value"), when the
  210. cookie should expire ("expire=DATE"), for what domain to use it
  211. ("domain=NAME") and if it should be used on secure connections only
  212. ("secure").
  213. If you've received a page from a server that contains a header like:
  214. Set-Cookie: sessionid=boo123; path="/foo";
  215. it means the server wants that first pair passed on when we get anything in
  216. a path beginning with "/foo".
  217. Example, get a page that wants my name passed in a cookie:
  218. curl -b "name=Daniel" www.sillypage.com
  219. Curl also has the ability to use previously received cookies in following
  220. sessions. If you get cookies from a server and store them in a file in a
  221. manner similar to:
  222. curl --dump-header headers www.example.com
  223. ... you can then in a second connect to that (or another) site, use the
  224. cookies from the 'headers' file like:
  225. curl -b headers www.example.com
  226. While saving headers to a file is a working way to store cookies, it is
  227. however error-prone and not the prefered way to do this. Instead, make curl
  228. save the incoming cookies using the well-known netscape cookie format like
  229. this:
  230. curl -c cookies.txt www.example.com
  231. Note that by specifying -b you enable the "cookie awareness" and with -L
  232. you can make curl follow a location: (which often is used in combination
  233. with cookies). So that if a site sends cookies and a location, you can
  234. use a non-existing file to trigger the cookie awareness like:
  235. curl -L -b empty.txt www.example.com
  236. The file to read cookies from must be formatted using plain HTTP headers OR
  237. as netscape's cookie file. Curl will determine what kind it is based on the
  238. file contents. In the above command, curl will parse the header and store
  239. the cookies received from www.example.com. curl will send to the server the
  240. stored cookies which match the request as it follows the location. The
  241. file "empty.txt" may be a non-existant file.
  242. Alas, to both read and write cookies from a netscape cookie file, you can
  243. set both -b and -c to use the same file:
  244. curl -b cookies.txt -c cookies.txt www.example.com
  245. PROGRESS METER
  246. The progress meter exists to show a user that something actually is
  247. happening. The different fields in the output have the following meaning:
  248. % Total % Received % Xferd Average Speed Time Curr.
  249. Dload Upload Total Current Left Speed
  250. 0 151M 0 38608 0 0 9406 0 4:41:43 0:00:04 4:41:39 9287
  251. From left-to-right:
  252. % - percentage completed of the whole transfer
  253. Total - total size of the whole expected transfer
  254. % - percentage completed of the download
  255. Received - currently downloaded amount of bytes
  256. % - percentage completed of the upload
  257. Xferd - currently uploaded amount of bytes
  258. Average Speed
  259. Dload - the average transfer speed of the download
  260. Average Speed
  261. Upload - the average transfer speed of the upload
  262. Time Total - expected time to complete the operation
  263. Time Current - time passed since the invoke
  264. Time Left - expected time left to completetion
  265. Curr.Speed - the average transfer speed the last 5 seconds (the first
  266. 5 seconds of a transfer is based on less time of course.)
  267. The -# option will display a totally different progress bar that doesn't
  268. need much explanation!
  269. SPEED LIMIT
  270. Curl allows the user to set the transfer speed conditions that must be met
  271. to let the transfer keep going. By using the switch -y and -Y you
  272. can make curl abort transfers if the transfer speed is below the specified
  273. lowest limit for a specified time.
  274. To have curl abort the download if the speed is slower than 3000 bytes per
  275. second for 1 minute, run:
  276. curl -Y 3000 -y 60 www.far-away-site.com
  277. This can very well be used in combination with the overall time limit, so
  278. that the above operatioin must be completed in whole within 30 minutes:
  279. curl -m 1800 -Y 3000 -y 60 www.far-away-site.com
  280. Forcing curl not to transfer data faster than a given rate is also possible,
  281. which might be useful if you're using a limited bandwidth connection and you
  282. don't want your transfer to use all of it (sometimes referred to as
  283. "bandwith throttle").
  284. Make curl transfer data no faster than 10 kilobytes per second:
  285. curl --limit-rate 10K www.far-away-site.com
  286. or
  287. curl --limit-rate 10240 www.far-away-site.com
  288. Or prevent curl from uploading data faster than 1 megabyte per second:
  289. curl -T upload --limit-rate 1M ftp://uploadshereplease.com
  290. When using the --limit-rate option, the transfer rate is regulated on a
  291. per-second basis, which will cause the total transfer speed to become lower
  292. than the given number. Sometimes of course substantially lower, if your
  293. transfer stalls during periods.
  294. CONFIG FILE
  295. Curl automatically tries to read the .curlrc file (or _curlrc file on win32
  296. systems) from the user's home dir on startup.
  297. The config file could be made up with normal command line switches, but you
  298. can also specify the long options without the dashes to make it more
  299. readable. You can separate the options and the parameter with spaces, or
  300. with = or :. Comments can be used within the file. If the first letter on a
  301. line is a '#'-letter the rest of the line is treated as a comment.
  302. If you want the parameter to contain spaces, you must inclose the entire
  303. parameter within double quotes ("). Within those quotes, you specify a
  304. quote as \".
  305. NOTE: You must specify options and their arguments on the same line.
  306. Example, set default time out and proxy in a config file:
  307. # We want a 30 minute timeout:
  308. -m 1800
  309. # ... and we use a proxy for all accesses:
  310. proxy = proxy.our.domain.com:8080
  311. White spaces ARE significant at the end of lines, but all white spaces
  312. leading up to the first characters of each line are ignored.
  313. Prevent curl from reading the default file by using -q as the first command
  314. line parameter, like:
  315. curl -q www.thatsite.com
  316. Force curl to get and display a local help page in case it is invoked
  317. without URL by making a config file similar to:
  318. # default url to get
  319. url = "http://help.with.curl.com/curlhelp.html"
  320. You can specify another config file to be read by using the -K/--config
  321. flag. If you set config file name to "-" it'll read the config from stdin,
  322. which can be handy if you want to hide options from being visible in process
  323. tables etc:
  324. echo "user = user:passwd" | curl -K - http://that.secret.site.com
  325. EXTRA HEADERS
  326. When using curl in your own very special programs, you may end up needing
  327. to pass on your own custom headers when getting a web page. You can do
  328. this by using the -H flag.
  329. Example, send the header "X-you-and-me: yes" to the server when getting a
  330. page:
  331. curl -H "X-you-and-me: yes" www.love.com
  332. This can also be useful in case you want curl to send a different text in a
  333. header than it normally does. The -H header you specify then replaces the
  334. header curl would normally send. If you replace an internal header with an
  335. empty one, you prevent that header from being sent. To prevent the Host:
  336. header from being used:
  337. curl -H "Host:" www.server.com
  338. FTP and PATH NAMES
  339. Do note that when getting files with the ftp:// URL, the given path is
  340. relative the directory you enter. To get the file 'README' from your home
  341. directory at your ftp site, do:
  342. curl ftp://user:passwd@my.site.com/README
  343. But if you want the README file from the root directory of that very same
  344. site, you need to specify the absolute file name:
  345. curl ftp://user:passwd@my.site.com//README
  346. (I.e with an extra slash in front of the file name.)
  347. FTP and firewalls
  348. The FTP protocol requires one of the involved parties to open a second
  349. connction as soon as data is about to get transfered. There are two ways to
  350. do this.
  351. The default way for curl is to issue the PASV command which causes the
  352. server to open another port and await another connection performed by the
  353. client. This is good if the client is behind a firewall that don't allow
  354. incoming connections.
  355. curl ftp.download.com
  356. If the server for example, is behind a firewall that don't allow connections
  357. on other ports than 21 (or if it just doesn't support the PASV command), the
  358. other way to do it is to use the PORT command and instruct the server to
  359. connect to the client on the given (as parameters to the PORT command) IP
  360. number and port.
  361. The -P flag to curl supports a few different options. Your machine may have
  362. several IP-addresses and/or network interfaces and curl allows you to select
  363. which of them to use. Default address can also be used:
  364. curl -P - ftp.download.com
  365. Download with PORT but use the IP address of our 'le0' interface (this does
  366. not work on windows):
  367. curl -P le0 ftp.download.com
  368. Download with PORT but use 192.168.0.10 as our IP address to use:
  369. curl -P 192.168.0.10 ftp.download.com
  370. NETWORK INTERFACE
  371. Get a web page from a server using a specified port for the interface:
  372. curl --interface eth0:1 http://www.netscape.com/
  373. or
  374. curl --interface 192.168.1.10 http://www.netscape.com/
  375. HTTPS
  376. Secure HTTP requires SSL libraries to be installed and used when curl is
  377. built. If that is done, curl is capable of retrieving and posting documents
  378. using the HTTPS procotol.
  379. Example:
  380. curl https://www.secure-site.com
  381. Curl is also capable of using your personal certificates to get/post files
  382. from sites that require valid certificates. The only drawback is that the
  383. certificate needs to be in PEM-format. PEM is a standard and open format to
  384. store certificates with, but it is not used by the most commonly used
  385. browsers (Netscape and MSIE both use the so called PKCS#12 format). If you
  386. want curl to use the certificates you use with your (favourite) browser, you
  387. may need to download/compile a converter that can convert your browser's
  388. formatted certificates to PEM formatted ones. This kind of converter is
  389. included in recent versions of OpenSSL, and for older versions Dr Stephen
  390. N. Henson has written a patch for SSLeay that adds this functionality. You
  391. can get his patch (that requires an SSLeay installation) from his site at:
  392. http://www.drh-consultancy.demon.co.uk/
  393. Example on how to automatically retrieve a document using a certificate with
  394. a personal password:
  395. curl -E /path/to/cert.pem:password https://secure.site.com/
  396. If you neglect to specify the password on the command line, you will be
  397. prompted for the correct password before any data can be received.
  398. Many older SSL-servers have problems with SSLv3 or TLS, that newer versions
  399. of OpenSSL etc is using, therefore it is sometimes useful to specify what
  400. SSL-version curl should use. Use -3, -2 or -1 to specify that exact SSL
  401. version to use (for SSLv3, SSLv2 or TLSv1 respectively):
  402. curl -2 https://secure.site.com/
  403. Otherwise, curl will first attempt to use v3 and then v2.
  404. To use OpenSSL to convert your favourite browser's certificate into a PEM
  405. formatted one that curl can use, do something like this (assuming netscape,
  406. but IE is likely to work similarly):
  407. You start with hitting the 'security' menu button in netscape.
  408. Select 'certificates->yours' and then pick a certificate in the list
  409. Press the 'export' button
  410. enter your PIN code for the certs
  411. select a proper place to save it
  412. Run the 'openssl' application to convert the certificate. If you cd to the
  413. openssl installation, you can do it like:
  414. # ./apps/openssl pkcs12 -in [file you saved] -clcerts -out [PEMfile]
  415. RESUMING FILE TRANSFERS
  416. To continue a file transfer where it was previously aborted, curl supports
  417. resume on http(s) downloads as well as ftp uploads and downloads.
  418. Continue downloading a document:
  419. curl -C - -o file ftp://ftp.server.com/path/file
  420. Continue uploading a document(*1):
  421. curl -C - -T file ftp://ftp.server.com/path/file
  422. Continue downloading a document from a web server(*2):
  423. curl -C - -o file http://www.server.com/
  424. (*1) = This requires that the ftp server supports the non-standard command
  425. SIZE. If it doesn't, curl will say so.
  426. (*2) = This requires that the web server supports at least HTTP/1.1. If it
  427. doesn't, curl will say so.
  428. TIME CONDITIONS
  429. HTTP allows a client to specify a time condition for the document it
  430. requests. It is If-Modified-Since or If-Unmodified-Since. Curl allow you to
  431. specify them with the -z/--time-cond flag.
  432. For example, you can easily make a download that only gets performed if the
  433. remote file is newer than a local copy. It would be made like:
  434. curl -z local.html http://remote.server.com/remote.html
  435. Or you can download a file only if the local file is newer than the remote
  436. one. Do this by prepending the date string with a '-', as in:
  437. curl -z -local.html http://remote.server.com/remote.html
  438. You can specify a "free text" date as condition. Tell curl to only download
  439. the file if it was updated since yesterday:
  440. curl -z yesterday http://remote.server.com/remote.html
  441. Curl will then accept a wide range of date formats. You always make the date
  442. check the other way around by prepending it with a dash '-'.
  443. DICT
  444. For fun try
  445. curl dict://dict.org/m:curl
  446. curl dict://dict.org/d:heisenbug:jargon
  447. curl dict://dict.org/d:daniel:web1913
  448. Aliases for 'm' are 'match' and 'find', and aliases for 'd' are 'define'
  449. and 'lookup'. For example,
  450. curl dict://dict.org/find:curl
  451. Commands that break the URL description of the RFC (but not the DICT
  452. protocol) are
  453. curl dict://dict.org/show:db
  454. curl dict://dict.org/show:strat
  455. Authentication is still missing (but this is not required by the RFC)
  456. LDAP
  457. If you have installed the OpenLDAP library, curl can take advantage of it
  458. and offer ldap:// support.
  459. LDAP is a complex thing and writing an LDAP query is not an easy task. I do
  460. advice you to dig up the syntax description for that elsewhere. Two places
  461. that might suit you are:
  462. Netscape's "Netscape Directory SDK 3.0 for C Programmer's Guide Chapter 10:
  463. Working with LDAP URLs":
  464. http://developer.netscape.com/docs/manuals/dirsdk/csdk30/url.htm
  465. RFC 2255, "The LDAP URL Format" http://www.rfc-editor.org/rfc/rfc2255.txt
  466. To show you an example, this is now I can get all people from my local LDAP
  467. server that has a certain sub-domain in their email address:
  468. curl -B "ldap://ldap.frontec.se/o=frontec??sub?mail=*sth.frontec.se"
  469. If I want the same info in HTML format, I can get it by not using the -B
  470. (enforce ASCII) flag.
  471. ENVIRONMENT VARIABLES
  472. Curl reads and understands the following environment variables:
  473. http_proxy, HTTPS_PROXY, FTP_PROXY, GOPHER_PROXY
  474. They should be set for protocol-specific proxies. General proxy should be
  475. set with
  476. ALL_PROXY
  477. A comma-separated list of host names that shouldn't go through any proxy is
  478. set in (only an asterisk, '*' matches all hosts)
  479. NO_PROXY
  480. If a tail substring of the domain-path for a host matches one of these
  481. strings, transactions with that node will not be proxied.
  482. The usage of the -x/--proxy flag overrides the environment variables.
  483. NETRC
  484. Unix introduced the .netrc concept a long time ago. It is a way for a user
  485. to specify name and password for commonly visited ftp sites in a file so
  486. that you don't have to type them in each time you visit those sites. You
  487. realize this is a big security risk if someone else gets hold of your
  488. passwords, so therefor most unix programs won't read this file unless it is
  489. only readable by yourself (curl doesn't care though).
  490. Curl supports .netrc files if told so (using the -n/--netrc and
  491. --netrc-optional options). This is not restricted to only ftp,
  492. but curl can use it for all protocols where authentication is used.
  493. A very simple .netrc file could look something like:
  494. machine curl.haxx.se login iamdaniel password mysecret
  495. CUSTOM OUTPUT
  496. To better allow script programmers to get to know about the progress of
  497. curl, the -w/--write-out option was introduced. Using this, you can specify
  498. what information from the previous transfer you want to extract.
  499. To display the amount of bytes downloaded together with some text and an
  500. ending newline:
  501. curl -w 'We downloaded %{size_download} bytes\n' www.download.com
  502. KERBEROS4 FTP TRANSFER
  503. Curl supports kerberos4 for FTP transfers. You need the kerberos package
  504. installed and used at curl build time for it to be used.
  505. First, get the krb-ticket the normal way, like with the kauth tool. Then use
  506. curl in way similar to:
  507. curl --krb4 private ftp://krb4site.com -u username:fakepwd
  508. There's no use for a password on the -u switch, but a blank one will make
  509. curl ask for one and you already entered the real password to kauth.
  510. TELNET
  511. The curl telnet support is basic and very easy to use. Curl passes all data
  512. passed to it on stdin to the remote server. Connect to a remote telnet
  513. server using a command line similar to:
  514. curl telnet://remote.server.com
  515. And enter the data to pass to the server on stdin. The result will be sent
  516. to stdout or to the file you specify with -o.
  517. You might want the -N/--no-buffer option to switch off the buffered output
  518. for slow connections or similar.
  519. Pass options to the telnet protocol negotiation, by using the -t option. To
  520. tell the server we use a vt100 terminal, try something like:
  521. curl -tTTYPE=vt100 telnet://remote.server.com
  522. Other interesting options for it -t include:
  523. - XDISPLOC=<X display> Sets the X display location.
  524. - NEW_ENV=<var,val> Sets an environment variable.
  525. NOTE: the telnet protocol does not specify any way to login with a specified
  526. user and password so curl can't do that automatically. To do that, you need
  527. to track when the login prompt is received and send the username and
  528. password accordingly.
  529. PERSISTANT CONNECTIONS
  530. Specifying multiple files on a single command line will make curl transfer
  531. all of them, one after the other in the specified order.
  532. libcurl will attempt to use persistant connections for the transfers so that
  533. the second transfer to the same host can use the same connection that was
  534. already initiated and was left open in the previous transfer. This greatly
  535. decreases connection time for all but the first transfer and it makes a far
  536. better use of the network.
  537. Note that curl cannot use persistant connections for transfers that are used
  538. in subsequence curl invokes. Try to stuff as many URLs as possible on the
  539. same command line if they are using the same host, as that'll make the
  540. transfers faster. If you use a http proxy for file transfers, practicly
  541. all transfers will be persistant.
  542. MAILING LISTS
  543. For your convenience, we have several open mailing lists to discuss curl,
  544. its development and things relevant to this. Get all info at
  545. http://curl.haxx.se/mail/. The lists available are:
  546. curl-users
  547. Users of the command line tool. How to use it, what doesn't work, new
  548. features, related tools, questions, news, installations, compilations,
  549. running, porting etc.
  550. curl-library
  551. Developers using or developing libcurl. Bugs, extensions, improvements.
  552. curl-announce
  553. Low-traffic. Only announcements of new public versions.
  554. curl-and-PHP
  555. Using the curl functions in PHP. Everything curl with a PHP angle. Or PHP
  556. with a curl angle.
  557. curl-commits
  558. Receives notifications on all CVS commits done to the curl source module.
  559. This can become quite a large amount of mails during intense development,
  560. be aware. This is for us who like email...
  561. curl-www-commits
  562. Receives notifications on all CVS commits done to the curl www module
  563. (basicly the web site). This can become quite a large amount of mails
  564. during intense changing, be aware. This is for us who like email...
  565. Please direct curl questions, feature requests and trouble reports to one of
  566. these mailing lists instead of mailing any individual.