write-out.d 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  2. SPDX-License-Identifier: curl
  3. Long: write-out
  4. Short: w
  5. Arg: <format>
  6. Help: Use output FORMAT after completion
  7. Category: verbose
  8. Example: -w '%{response_code}\\n' $URL
  9. Added: 6.5
  10. See-also: verbose head
  11. Multi: single
  12. ---
  13. Make curl display information on stdout after a completed transfer. The format
  14. is a string that may contain plain text mixed with any number of
  15. variables. The format can be specified as a literal "string", or you can have
  16. curl read the format from a file with "@filename" and to tell curl to read the
  17. format from stdin you write "@-".
  18. The variables present in the output format will be substituted by the value or
  19. text that curl thinks fit, as described below. All variables are specified as
  20. %{variable_name} and to output a normal % you just write them as %%. You can
  21. output a newline by using \\n, a carriage return with \\r and a tab space with
  22. \\t.
  23. The output will be written to standard output, but this can be switched to
  24. standard error by using %{stderr}.
  25. Output HTTP headers from the most recent request by using *%header{name}*
  26. where *name* is the case insensitive name of the header (without the trailing
  27. colon). The header contents are exactly as sent over the network, with leading
  28. and trailing whitespace trimmed. Added in curl 7.84.0.
  29. Select a specific target destination file to write the output to, by using
  30. *%output{name}* where *name* is the full file name. The output following that
  31. instruction is then written to that file. More than one *%output{}* instruction
  32. can be specified in the same write-out argument. If the file name cannot be
  33. created, curl will leave the output to the one used prior to the *%output{}*
  34. instruction. Use *%output{>>name}* to append data to an existing file. Added in
  35. curl 8.3.0.
  36. **NOTE:**
  37. In Windows the %-symbol is a special symbol used to expand environment
  38. variables. In batch files all occurrences of % must be doubled when using this
  39. option to properly escape. If this option is used at the command prompt then
  40. the % cannot be escaped and unintended expansion is possible.
  41. The variables available are:
  42. .RS
  43. .TP 15
  44. **certs**
  45. Output the certificate chain with details. Supported only by the OpenSSL,
  46. GnuTLS, Schannel, GSKit and Secure Transport backends. (Added in 7.88.0)
  47. .TP
  48. **content_type**
  49. The Content-Type of the requested document, if there was any.
  50. .TP
  51. **errormsg**
  52. The error message. (Added in 7.75.0)
  53. .TP
  54. **exitcode**
  55. The numerical exit code of the transfer. (Added in 7.75.0)
  56. .TP
  57. **filename_effective**
  58. The ultimate filename that curl writes out to. This is only meaningful if curl
  59. is told to write to a file with the --remote-name or --output
  60. option. It's most useful in combination with the --remote-header-name
  61. option. (Added in 7.26.0)
  62. .TP
  63. **ftp_entry_path**
  64. The initial path curl ended up in when logging on to the remote FTP
  65. server. (Added in 7.15.4)
  66. .TP
  67. **header_json**
  68. A JSON object with all HTTP response headers from the recent transfer. Values
  69. are provided as arrays, since in the case of multiple headers there can be
  70. multiple values. (Added in 7.83.0)
  71. The header names provided in lowercase, listed in order of appearance over the
  72. wire. Except for duplicated headers. They are grouped on the first occurrence
  73. of that header, each value is presented in the JSON array.
  74. .TP
  75. **http_code**
  76. The numerical response code that was found in the last retrieved HTTP(S) or
  77. FTP(s) transfer.
  78. .TP
  79. **http_connect**
  80. The numerical code that was found in the last response (from a proxy) to a
  81. curl CONNECT request. (Added in 7.12.4)
  82. .TP
  83. **http_version**
  84. The http version that was effectively used. (Added in 7.50.0)
  85. .TP
  86. **json**
  87. A JSON object with all available keys.
  88. .TP
  89. **local_ip**
  90. The IP address of the local end of the most recently done connection - can be
  91. either IPv4 or IPv6. (Added in 7.29.0)
  92. .TP
  93. **local_port**
  94. The local port number of the most recently done connection. (Added in 7.29.0)
  95. .TP
  96. **method**
  97. The http method used in the most recent HTTP request. (Added in 7.72.0)
  98. .TP
  99. **num_certs**
  100. Number of server certificates received in the TLS handshake. Supported only by
  101. the OpenSSL, GnuTLS, Schannel, GSKit and Secure Transport backends. (Added
  102. in 7.88.0)
  103. .TP
  104. **num_connects**
  105. Number of new connects made in the recent transfer. (Added in 7.12.3)
  106. .TP
  107. **num_headers**
  108. The number of response headers in the most recent request (restarted at each
  109. redirect). Note that the status line IS NOT a header. (Added in 7.73.0)
  110. .TP
  111. **num_redirects**
  112. Number of redirects that were followed in the request. (Added in 7.12.3)
  113. .TP
  114. **onerror**
  115. The rest of the output is only shown if the transfer returned a non-zero error.
  116. (Added in 7.75.0)
  117. .TP
  118. **proxy_ssl_verify_result**
  119. The result of the HTTPS proxy's SSL peer certificate verification that was
  120. requested. 0 means the verification was successful. (Added in 7.52.0)
  121. .TP
  122. **redirect_url**
  123. When an HTTP request was made without --location to follow redirects (or when
  124. --max-redirs is met), this variable will show the actual URL a redirect
  125. *would* have gone to. (Added in 7.18.2)
  126. .TP
  127. **referer**
  128. The Referer: header, if there was any. (Added in 7.76.0)
  129. .TP
  130. **remote_ip**
  131. The remote IP address of the most recently done connection - can be either
  132. IPv4 or IPv6. (Added in 7.29.0)
  133. .TP
  134. **remote_port**
  135. The remote port number of the most recently done connection. (Added in 7.29.0)
  136. .TP
  137. **response_code**
  138. The numerical response code that was found in the last transfer (formerly
  139. known as "http_code"). (Added in 7.18.2)
  140. .TP
  141. **scheme**
  142. The URL scheme (sometimes called protocol) that was effectively used. (Added in 7.52.0)
  143. .TP
  144. **size_download**
  145. The total amount of bytes that were downloaded. This is the size of the
  146. body/data that was transferred, excluding headers.
  147. .TP
  148. **size_header**
  149. The total amount of bytes of the downloaded headers.
  150. .TP
  151. **size_request**
  152. The total amount of bytes that were sent in the HTTP request.
  153. .TP
  154. **size_upload**
  155. The total amount of bytes that were uploaded. This is the size of the
  156. body/data that was transferred, excluding headers.
  157. .TP
  158. **speed_download**
  159. The average download speed that curl measured for the complete download. Bytes
  160. per second.
  161. .TP
  162. **speed_upload**
  163. The average upload speed that curl measured for the complete upload. Bytes per
  164. second.
  165. .TP
  166. **ssl_verify_result**
  167. The result of the SSL peer certificate verification that was requested. 0
  168. means the verification was successful. (Added in 7.19.0)
  169. .TP
  170. **stderr**
  171. From this point on, the --write-out output will be written to standard
  172. error. (Added in 7.63.0)
  173. .TP
  174. **stdout**
  175. From this point on, the --write-out output will be written to standard output.
  176. This is the default, but can be used to switch back after switching to stderr.
  177. (Added in 7.63.0)
  178. .TP
  179. **time_appconnect**
  180. The time, in seconds, it took from the start until the SSL/SSH/etc
  181. connect/handshake to the remote host was completed. (Added in 7.19.0)
  182. .TP
  183. **time_connect**
  184. The time, in seconds, it took from the start until the TCP connect to the
  185. remote host (or proxy) was completed.
  186. .TP
  187. **time_namelookup**
  188. The time, in seconds, it took from the start until the name resolving was
  189. completed.
  190. .TP
  191. **time_pretransfer**
  192. The time, in seconds, it took from the start until the file transfer was just
  193. about to begin. This includes all pre-transfer commands and negotiations that
  194. are specific to the particular protocol(s) involved.
  195. .TP
  196. **time_redirect**
  197. The time, in seconds, it took for all redirection steps including name lookup,
  198. connect, pretransfer and transfer before the final transaction was
  199. started. time_redirect shows the complete execution time for multiple
  200. redirections. (Added in 7.12.3)
  201. .TP
  202. **time_starttransfer**
  203. The time, in seconds, it took from the start until the first byte was just
  204. about to be transferred. This includes time_pretransfer and also the time the
  205. server needed to calculate the result.
  206. .TP
  207. **time_total**
  208. The total time, in seconds, that the full operation lasted.
  209. .TP
  210. **url**
  211. The URL that was fetched. (Added in 7.75.0)
  212. .TP
  213. **url.scheme**
  214. The scheme part of the URL that was fetched. (Added in 8.1.0)
  215. .TP
  216. **url.user**
  217. The user part of the URL that was fetched. (Added in 8.1.0)
  218. .TP
  219. **url.password**
  220. The password part of the URL that was fetched. (Added in 8.1.0)
  221. .TP
  222. **url.options**
  223. The options part of the URL that was fetched. (Added in 8.1.0)
  224. .TP
  225. **url.host**
  226. The host part of the URL that was fetched. (Added in 8.1.0)
  227. .TP
  228. **url.port**
  229. The port number of the URL that was fetched. If no port number was specified,
  230. but the URL scheme is known, that scheme's default port number is
  231. shown. (Added in 8.1.0)
  232. .TP
  233. **url.path**
  234. The path part of the URL that was fetched. (Added in 8.1.0)
  235. .TP
  236. **url.query**
  237. The query part of the URL that was fetched. (Added in 8.1.0)
  238. .TP
  239. **url.fragment**
  240. The fragment part of the URL that was fetched. (Added in 8.1.0)
  241. .TP
  242. **url.zoneid**
  243. The zone id part of the URL that was fetched. (Added in 8.1.0)
  244. .TP
  245. **urle.scheme**
  246. The scheme part of the effective (last) URL that was fetched. (Added in 8.1.0)
  247. .TP
  248. **urle.user**
  249. The user part of the effective (last) URL that was fetched. (Added in 8.1.0)
  250. .TP
  251. **urle.password**
  252. The password part of the effective (last) URL that was fetched. (Added in 8.1.0)
  253. .TP
  254. **urle.options**
  255. The options part of the effective (last) URL that was fetched. (Added in 8.1.0)
  256. .TP
  257. **urle.host**
  258. The host part of the effective (last) URL that was fetched. (Added in 8.1.0)
  259. .TP
  260. **urle.port**
  261. The port number of the effective (last) URL that was fetched. If no port
  262. number was specified, but the URL scheme is known, that scheme's default port
  263. number is shown. (Added in 8.1.0)
  264. .TP
  265. **urle.path**
  266. The path part of the effective (last) URL that was fetched. (Added in 8.1.0)
  267. .TP
  268. **urle.query**
  269. The query part of the effective (last) URL that was fetched. (Added in 8.1.0)
  270. .TP
  271. **urle.fragment**
  272. The fragment part of the effective (last) URL that was fetched. (Added in 8.1.0)
  273. .TP
  274. **urle.zoneid**
  275. The zone id part of the effective (last) URL that was fetched. (Added in 8.1.0)
  276. .TP
  277. **urlnum**
  278. The URL index number of this transfer, 0-indexed. Unglobbed URLs share the
  279. same index number as the origin globbed URL. (Added in 7.75.0)
  280. .TP
  281. **url_effective**
  282. The URL that was fetched last. This is most meaningful if you have told curl
  283. to follow location: headers.
  284. .RE
  285. .IP