You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ftp.html 28 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  5. <title>FTP Task</title>
  6. </head>
  7. <body>
  8. <h2><a name="ftp">FTP</a></h2>
  9. <h3>Description</h3>
  10. <p>The ftp task implements a basic FTP client that can send, receive,
  11. list, delete files, and create directories. See below for descriptions and examples of how
  12. to perform each task.</p>
  13. <p><b>Note:</b> This task depends on external libraries not included in the Ant distribution.
  14. See <a href="../install.html#commons-net">Library Dependencies</a> for more information.</p>
  15. <p>The ftp task attempts to determine what file system is in place on the FTP server.
  16. Supported server types are Unix, NT, OS2, VMS, and OS400. In addition, NT and OS400 servers
  17. which have been configured to display the directory in Unix style are also supported correctly.
  18. Otherwise, the system will default to Unix standards.
  19. <i>remotedir</i> must be specified in the exact syntax required by the ftp
  20. server. If the usual Unix conventions are not supported by the server,
  21. <i>separator</i> can be used to set the file separator that should be used
  22. instead.</p>
  23. <p>See the section on <a href="../dirtasks.html#directorybasedtasks">directory based
  24. tasks</a>, on how the inclusion/exclusion of files works, and how to
  25. write patterns.</p>
  26. <p>
  27. This task does not currently use the proxy information set by the
  28. <a href="setproxy.html"><code>&lt;setproxy&gt;</code></a> task, and cannot go through
  29. a firewall via socks.
  30. <p>
  31. <b>Warning: </b> there have been problems reported concerning the ftp get with newer attribute.
  32. Problems might be due to format of ls -l differing from what is expected by commons-net,
  33. for instance due to specificities of language used by the ftp server in the directory listing.
  34. If you encounter such a problem, please send an email including a sample directory listing
  35. coming from your ftp server (ls -l on the ftp prompt).
  36. <h3>Parameters</h3>
  37. <table border="1" cellpadding="2" cellspacing="0">
  38. <tr>
  39. <td valign="top" width="15%"><b>Attribute</b></td>
  40. <td valign="top" width="65%"><b>Description</b></td>
  41. <td align="center" valign="top" width="20%"><b>Required</b></td>
  42. </tr>
  43. <tr>
  44. <td valign="top">server</td>
  45. <td valign="top">the address of the remote ftp server.</td>
  46. <td valign="top" align="center">Yes</td>
  47. </tr>
  48. <tr>
  49. <td valign="top">port</td>
  50. <td valign="top">the port number of the remote ftp server.
  51. Defaults to port 21.</td>
  52. <td valign="top" align="center">No</td>
  53. </tr>
  54. <tr>
  55. <td valign="top">userid</td>
  56. <td valign="top">the login id to use on the ftp server.</td>
  57. <td valign="top" align="center">Yes</td>
  58. </tr>
  59. <tr>
  60. <td valign="top">password</td>
  61. <td valign="top">the login password to use on the ftp server.</td>
  62. <td valign="top" align="center">Yes</td>
  63. </tr>
  64. <tr>
  65. <td valign="top">remotedir</td>
  66. <td valign="top">remote directory on the
  67. ftp server
  68. see table below for detailed usage
  69. </td>
  70. <td valign="top" align="center">No</td>
  71. </tr>
  72. <tr>
  73. <td valign="top">action</td>
  74. <td valign="top">the ftp action to perform, defaulting to "send".
  75. Currently supports "put", "get",
  76. "del", "list", "chmod",
  77. "mkdir" and "rmdir".</td>
  78. <td valign="top" align="center">No</td>
  79. </tr>
  80. <tr>
  81. <td valign="top">binary</td>
  82. <td valign="top">selects binary-mode ("yes") or text-mode
  83. ("no") transfers.
  84. Defaults to "yes"</td>
  85. <td valign="top" align="center">No</td>
  86. </tr>
  87. <tr>
  88. <td valign="top">passive</td>
  89. <td valign="top">selects passive-mode ("yes") transfers.
  90. Defaults to "no"</td>
  91. <td valign="top" align="center">No</td>
  92. </tr>
  93. <tr>
  94. <td valign="top">verbose</td>
  95. <td valign="top">displays information on each file transferred if set
  96. to "yes". Defaults to "no".</td>
  97. <td valign="top" align="center">No</td>
  98. </tr>
  99. <tr>
  100. <td valign="top">depends</td>
  101. <td valign="top">transfers only new or changed files if set to
  102. "yes". Defaults to "no".</td>
  103. <td valign="top" align="center">No</td>
  104. </tr>
  105. <tr>
  106. <td valign="top">newer</td>
  107. <td valign="top">a synonym for <i>depends</i>.
  108. see timediffauto and timediffmillis</td>
  109. <td valign="top" align="center">No</td>
  110. </tr>
  111. <tr>
  112. <td valign="top">timediffauto</td>
  113. <td valign="top">set to <code>"true"</code>
  114. to make ant calculate the time difference between client and server.<br>
  115. <em>requires write access in the remote directory</em><br>
  116. Since ant 1.6</td>
  117. <td valign="top" align="center">No</td>
  118. </tr>
  119. <a name="timestampGranularity"/>
  120. <tr>
  121. <td valign="top">timestampGranularity</td>
  122. <td valign="top">Specify either <code>MINUTE</code>, <code>NONE</code>,
  123. (or you may specify <code>""</code> which is equivalent to not specifying a value,
  124. useful for property-file driven scripts). Allows override of the typical situation
  125. in PUT and GET where local filesystem timestamps are <code>HH:mm:ss</code>
  126. and the typical FTP server's timestamps are <code>HH:mm</code>. This can throw
  127. off uptodate calculations. However, the default values should suffice for most
  128. applications.<br>
  129. Since ant 1.7
  130. </td>
  131. <td valign="top" align="center">No. Only applies in "puts" and "gets" where the
  132. default values are <code>MINUTE</code> for PUT and <code>NONE</code> for GET.
  133. (It is not as necessary in GET because we have the <b>preservelastmodified</b> option.)</td>
  134. </tr>
  135. <tr>
  136. <td valign="top">timediffmillis</td>
  137. <td valign="top"><b>Deprecated</b>. Number of milliseconds to add to the time on
  138. the remote machine to get the time on the local machine. The <b>timestampGranularity</b>
  139. attribute (for which the default values should suffice in most situations), and the
  140. <b>serverTimeZoneConfig</b> option, should make this unnecessary.
  141. <b>serverTimeZoneConfig</b> does the math for you and also knows about
  142. Daylight Savings Time.<br>
  143. Since ant 1.6
  144. </td>
  145. <td valign="top" align="center">No</td>
  146. </tr>
  147. <tr>
  148. <td valign="top">separator</td>
  149. <td valign="top">sets the file separator used on the ftp server.
  150. Defaults to "/".</td>
  151. <td valign="top" align="center">No</td>
  152. </tr>
  153. <tr>
  154. <td valign="top">umask</td>
  155. <td valign="top">sets the default file permissions for new files,
  156. unix only.</td>
  157. <td valign="top" align="center">No</td>
  158. </tr>
  159. <tr>
  160. <td valign="top">chmod</td>
  161. <td valign="top">sets or changes file permissions for new or existing files,
  162. unix only. If used with a put action, chmod will be issued for each file.</td>
  163. <td valign="top" align="center">No</td>
  164. </tr>
  165. <tr>
  166. <td valign="top">listing</td>
  167. <td valign="top">the file to write results of the "list" action.
  168. Required for the "list" action, ignored otherwise.</td>
  169. <td valign="top" align="center">No</td>
  170. </tr>
  171. <tr>
  172. <td valign="top">ignoreNoncriticalErrors</td>
  173. <td valign="top">flag which permits the task to ignore some non-fatal error
  174. codes sent by some servers during directory creation: wu-ftp in particular.
  175. Default: false</td>
  176. <td valign="top" align="center">No</td>
  177. </tr>
  178. <tr>
  179. <td valign="top">skipFailedTransfers</td>
  180. <td valign="top">flag which enables unsuccessful file put, delete
  181. and get operations to be skipped with a warning and the
  182. remainder of the files still transferred. Default: false</td>
  183. <td valign="top" align="center">No</td>
  184. </tr>
  185. <tr>
  186. <td valign="top">preservelastmodified</td>
  187. <td valign="top">Give the copied files the same last modified
  188. time as the original source files (applies to getting files only).
  189. (<em>Note</em>: Ignored on Java 1.1)</td>
  190. <td valign="top" align="center">No; defaults to false.</td>
  191. </tr>
  192. <tr>
  193. <td valign="top">retriesAllowed</td>
  194. <td valign="top">Set the number of retries allowed on an file-transfer operation.
  195. If a number > 0 specified, each file transfer can fail up to that
  196. many times before the operation is failed. If -1 or "forever" specified, the
  197. operation will keep trying until it succeeds.</td>
  198. <td valign="top" align="center">No; defaults to 0</td>
  199. </tr>
  200. <tr>
  201. <td colspan="3">
  202. <p><b>The following attributes require <a href=
  203. "http://jakarta.apache.org/commons/net/download.html">
  204. jakarta-commons-net-1.4.0 or greater</a>.</b></p>
  205. <p>
  206. Use these options when the standard options don't work, because
  207. <ul><li>the server is in a different timezone and you need timestamp
  208. dependency checking</li>
  209. <li>the default timestamp formatting doesn't match the server display and
  210. list parsing therefore fails</li></ul>
  211. </p><p>
  212. If none of these is specified, the default mechanism of letting the system
  213. auto-detect the server OS type based on the FTP SYST command and assuming
  214. standard formatting for that OS type will be used.
  215. </p><p>
  216. To aid in property-file-based development where a build script is configured
  217. with property files, for any of these attributes, a value of <code>""</code>
  218. is equivalent to not specifying it.
  219. </p><p>
  220. Please understand that these options are incompatible with the autodetection
  221. scheme. If any of these options is specified, (other than with a value of
  222. <code>""</code> ) a system type must be chosen and if systemTypeKey is not
  223. specified, UNIX will be assumed. The philosophy behind this is that these
  224. options are for setting non-standard formats, and a build-script author who
  225. knows what system he is dealing with will know what options to need to be
  226. set. Otherwise, these options should be left alone and the default
  227. autodetection scheme can be used and will work in the majority of cases.
  228. </p></td>
  229. </tr>
  230. <tr>
  231. <td valign="top">systemTypeKey</td>
  232. <td valign="top">Specifies the type of system in use on the server.
  233. Supported values are <code>"UNIX", "VMS", "WINDOWS", "OS/2", "OS/400",
  234. "MVS".</code> If not specified, (or specified as <code>""</code>) and if
  235. no other xxxConfig attributes are specified, the autodectection mechanism
  236. based on the FTP SYST command will be used.<br>
  237. Since ant 1.7
  238. </td>
  239. <td valign="top" align="center">No, but if any of the following xxxConfig
  240. attributes is specified, UNIX will be assumed, even if <code>""</code>
  241. is specified here.
  242. </td>
  243. </tr>
  244. <tr>
  245. <td valign="top">serverTimeZoneConfig</td>
  246. <td valign="top">Specify as a Java
  247. <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/TimeZone.html">
  248. TimeZone</a> identifier, (e.g. <code>GMT</code>, <code>America/Chicago</code> or
  249. <code>Asia/Jakarta</code>) the timezone used by the server for timestamps. This
  250. enables timestamp dependency checking even when the server is in a different
  251. time zone from the client. Time Zones know, also, about daylight savings time,
  252. and do not require you to calculate milliseconds of difference. If not specified,
  253. (or specified as <code>""</code>), the time zone of the client is assumed.<br>
  254. Since ant 1.7
  255. </td>
  256. <td valign="top" align="center">No</td>
  257. </tr>
  258. <tr>
  259. <td valign="top">defaultDateFormatConfig</td>
  260. <td valign="top">Specify in Java
  261. <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html">
  262. SimpleDateFormat</a> notation, (e.g.
  263. <code>yyyy-MM-dd</code>), the date format generally used by the FTP server
  264. to parse dates. In some cases this will be the only date format used.
  265. In others, (unix for example) this will be used for dates
  266. older than a year old. (See <b>recentDateFormatConfig</b>). If not specified,
  267. (or specified as <code>""</code>), the default date format for the system
  268. type indicated by the <b>systemTypeKey</b> attribute will be used.<br>
  269. Since ant 1.7
  270. </td>
  271. <td valign="top" align="center">
  272. No.
  273. </td>
  274. </tr>
  275. <tr>
  276. <td valign="top">recentDateFormatConfig</td>
  277. <td valign="top">Specify in Java
  278. <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html">
  279. SimpleDateFormat</a> notation,
  280. (e.g. <code>MMM dd hh:mm</code>) the date format used by the FTP server
  281. to parse dates less than a year old. If not specified (or specified as
  282. <code>""</code>), and if the system type indicated by the system key uses
  283. a recent date format, its standard format will be used.<br>
  284. Since ant 1.7
  285. </td>
  286. <td valign="top" align="center">No</td>
  287. </tr>
  288. <tr>
  289. <td valign="top">serverLanguageCodeConfig</td>
  290. <td valign="top">a <a href="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt">
  291. two-letter ISO-639 language code</a> used to specify the
  292. language used by the server to format month names. This only needs to be
  293. specified when the server uses non-numeric abbreviations for months in its
  294. date listings in a language other than English. This appears to be
  295. becoming rarer and rarer, as commonly distributed ftp servers seem
  296. increasingly to use English or all-numeric formats.
  297. Languages supported are:
  298. <ul>
  299. <li>en - English</li>
  300. <li>fr - French</li>
  301. <li>de - German</li>
  302. <li>it - Italian</li>
  303. <li>es - Spanish</li>
  304. <li>pt - Portuguese</li>
  305. <li>da - Danish</li>
  306. <li>sv - Swedish</li>
  307. <li>no - Norwegian</li>
  308. <li>nl - Dutch</li>
  309. <li>ro - Romanian</li>
  310. <li>sq - Albanian</li>
  311. <li>sh - Serbo-croatian</li>
  312. <li>sk - Slovak</li>
  313. <li>sl - Slovenian</li>
  314. </ul>
  315. If you require a language other than the above, see also the
  316. <b>shortMonthNamesConfig</b> attribute.<br>
  317. Since ant 1.7
  318. </td>
  319. <td valign="top" align="center">No</td>
  320. </tr>
  321. <tr>
  322. <td valign="top">shortMonthNamesConfig</td>
  323. <td valign="top">specify the month abbreviations used on the server in file
  324. timestamp dates as a pipe-delimited string for each month. For example,
  325. a set of month names used by a hypothetical
  326. Icelandic FTP server might conceivably be specified as
  327. <code>"jan|feb|mar|apr|ma&#xED;|j&#xFA;n|j&#xFA;l|&#xE1;g&#xFA;|sep|okt|n&#xF3;v|des"</code>.
  328. This attribute exists primarily to support languages not supported by
  329. the <b>serverLanguageCode</b> attribute.<br>
  330. Since ant 1.7
  331. </td>
  332. <td valign="top" align="center">No</td>
  333. </tr>
  334. </table>
  335. <h3>Note about remotedir attribute</h3>
  336. <table border="1" cellpadding="2" cellspacing="0"
  337. >
  338. <tbody>
  339. <tr>
  340. <td style="vertical-align: top;" width="20%">Action<br>
  341. </td>
  342. <td style="vertical-align: top;" width="40%">meaning of <code>remotedir</code><br>
  343. </td>
  344. <td style="vertical-align: top;">use of nested <code>fileset</code>
  345. (s)<br>
  346. </td>
  347. </tr>
  348. <tr>
  349. <td style="vertical-align: top;" width="20%">send/put<br>
  350. </td>
  351. <td style="vertical-align: top;" width="40%">base directory to
  352. which the files are sent<br>
  353. </td>
  354. <td style="vertical-align: top;">they are used normally and
  355. evaluated on the local machine<br>
  356. </td>
  357. </tr>
  358. <tr>
  359. <td style="vertical-align: top;" width="20%">recv/get<br>
  360. </td>
  361. <td style="vertical-align: top;" width="40%">base directory from
  362. which the files are retrieved<br>
  363. </td>
  364. <td style="vertical-align: top;">the remote files located under
  365. the <code>remotedir </code>matching the include/exclude patterns of
  366. the <code>fileset&nbsp;</code></td>
  367. </tr>
  368. <tr>
  369. <td style="vertical-align: top;" width="20%">del/delete<br>
  370. </td>
  371. <td style="vertical-align: top;" width="40%">base directory from
  372. which files get deleted<br>
  373. </td>
  374. <td style="vertical-align: top;">the remote files located under
  375. the <code>remotedir </code>matching the include/exclude patterns of
  376. the <code>fileset <br>
  377. </code></td>
  378. </tr>
  379. <tr>
  380. <td style="vertical-align: top;" width="20%">list<br>
  381. </td>
  382. <td style="vertical-align: top;" width="40%">base directory from
  383. which files are listed<br>
  384. </td>
  385. <td style="vertical-align: top;">the remote files located under
  386. the <code>remotedir </code>matching the include/exclude patterns of
  387. the <code>fileset <br>
  388. </code></td>
  389. </tr>
  390. <tr>
  391. <td style="vertical-align: top;" width="20%">mkdir</td>
  392. <td style="vertical-align: top;" width="40%">directory to create<br>
  393. </td>
  394. <td style="vertical-align: top;">not used<br>
  395. </td>
  396. </tr>
  397. <tr>
  398. <td style="vertical-align: top;" width="20%">chmod</td>
  399. <td style="vertical-align: top;" width="40%">base directory from
  400. which the mode of files get changed<br>
  401. </td>
  402. <td style="vertical-align: top;">the remote files located under
  403. the <code>remotedir </code>matching the include/exclude patterns of
  404. the <code>fileset <br>
  405. </code></td>
  406. </tr>
  407. <tr>
  408. <td style="vertical-align: top;" width="20%">rmdir<br>
  409. </td>
  410. <td style="vertical-align: top;" width="40%">base directory from
  411. which directories get removed<br>
  412. </td>
  413. <td style="vertical-align: top;">the remote directories located
  414. under the <code>remotedir </code>matching the include/exclude
  415. patterns of the <code>fileset <br>
  416. </code></td>
  417. </tr>
  418. </tbody>
  419. </table><h3>Parameters specified as nested elements</h3>
  420. <h4>fileset</h4>
  421. <p>The ftp task supports any number of nested <a
  422. href="../CoreTypes/fileset.html"><code>&lt;fileset&gt;</code></a> elements to specify
  423. the files to be retrieved, or deleted, or listed, or whose mode you want to change.</p>
  424. <p>
  425. The attribute <code>followsymlinks</code> of <code>fileset</code> is supported on
  426. local (put) as well as remote (get, chmod, delete) filesets.
  427. <em>Before ant 1.6 there was no support of symbolic links in remote filesets.
  428. In order to exclude symbolic links (preserve the behavior of ant 1.5.x and older),
  429. you need to explicitly set <code>followsymlinks</code> to <code>false</code>.</em>
  430. On remote filesets hidden files are not checked for being symbolic links. Hidden
  431. files are currently assumed to not be symbolic links.
  432. </p>
  433. <p>
  434. Remote filesets do not support selectors.<br>
  435. </p>
  436. <h3>Sending Files</h3>
  437. <p>The easiest way to describe how to send files is with a couple of examples:</p>
  438. <pre>
  439. &lt;ftp server="ftp.apache.org"
  440. userid="anonymous"
  441. password="me@myorg.com"&gt;
  442. &lt;fileset dir="htdocs/manual"/&gt;
  443. &lt;/ftp&gt;
  444. </pre>
  445. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  446. uploads all files in the <code>htdocs/manual</code> directory
  447. to the default directory for that user.</p>
  448. <pre> &lt;ftp server="ftp.apache.org"
  449. remotedir="incoming"
  450. userid="anonymous"
  451. password="me@myorg.com"
  452. depends="yes"&gt;
  453. &lt;fileset dir="htdocs/manual"/&gt;
  454. &lt;/ftp&gt;</pre>
  455. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  456. uploads all new or changed files in the <code>htdocs/manual</code> directory
  457. to the <code>incoming</code> directory relative to the default directory
  458. for <code>anonymous</code>.</p>
  459. <pre> &lt;ftp server="ftp.apache.org"
  460. port="2121"
  461. remotedir="/pub/incoming"
  462. userid="coder"
  463. password="java1"
  464. passive="yes"
  465. depends="yes"
  466. binary="no"&gt;
  467. &lt;fileset dir="htdocs/manual"&gt;
  468. &lt;include name="**/*.html"/&gt;
  469. &lt;/fileset&gt;
  470. &lt;/ftp&gt;</pre>
  471. <p>Logs in to <code>ftp.apache.org</code> at port <code>2121</code> as
  472. <code>coder</code> with password <code>java1</code> and uploads all new or
  473. changed HTML files in the <code>htdocs/manual</code> directory to the
  474. <code>/pub/incoming</code> directory. The files are transferred in text mode.
  475. Passive mode has been switched on to send files from behind a firewall.</p>
  476. <pre> &lt;ftp server="ftp.hypothetical.india.org"
  477. port="2121"
  478. remotedir="/pub/incoming"
  479. userid="coder"
  480. password="java1"
  481. depends="yes"
  482. binary="no"
  483. systemTypeKey="Windows"
  484. serverTimeZoneConfig="India/Calcutta"&gt;
  485. &lt;fileset dir="htdocs/manual"&gt;
  486. &lt;include name="**/*.html"/&gt;
  487. &lt;/fileset&gt;
  488. &lt;/ftp&gt;</pre>
  489. <p>Logs in to a Windows server at <code>ftp.hypothetical.india.org</code>
  490. at port <code>2121</code> as <code>coder</code> with password <code>java1</code>
  491. and uploads all new or changed (accounting for timezone differences)
  492. HTML files in the <code>htdocs/manual</code>
  493. directory to the <code>/pub/incoming</code> directory. The files are transferred
  494. in text mode.</p>
  495. <pre> &lt;ftp server="ftp.nt.org"
  496. remotedir="c:\uploads"
  497. userid="coder"
  498. password="java1"
  499. separator="\"
  500. verbose="yes"&gt;
  501. &lt;fileset dir="htdocs/manual"&gt;
  502. &lt;include name="**/*.html"/&gt;
  503. &lt;/fileset&gt;
  504. &lt;/ftp&gt;</pre><p>Logs in to the Windows-based <code>ftp.nt.org</code> as
  505. <code>coder</code> with password <code>java1</code> and uploads all
  506. HTML files in the <code>htdocs/manual</code> directory to the
  507. <code>c:\uploads</code> directory. Progress messages are displayed as each
  508. file is uploaded.</p>
  509. <h3>Getting Files</h3>
  510. <p>Getting files from an FTP server works pretty much the same way as
  511. sending them does. The only difference is that the nested filesets
  512. use the remotedir attribute as the base directory for the files on the
  513. FTP server, and the dir attribute as the local directory to put the files
  514. into. The file structure from the FTP site is preserved on the local machine.</p>
  515. <pre>
  516. &lt;ftp action="get"
  517. server="ftp.apache.org"
  518. userid="anonymous"
  519. password="me@myorg.com"&gt;
  520. &lt;fileset dir="htdocs/manual"&gt;
  521. &lt;include name="**/*.html"/&gt;
  522. &lt;/fileset&gt;
  523. &lt;/ftp&gt;
  524. </pre>
  525. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  526. recursively downloads all .html files from default directory for that user
  527. into the <code>htdocs/manual</code> directory on the local machine.</p>
  528. <pre>
  529. &lt;ftp action="get"
  530. server="ftp.apache.org"
  531. userid="anonymous"
  532. password="me@myorg.com"
  533. systemTypeKey="UNIX"
  534. defaultDateFormatConfig="yyyy-MM-dd HH:mm"&gt;
  535. &lt;fileset dir="htdocs/manual"&gt;
  536. &lt;include name="**/*.html"/&gt;
  537. &lt;/fileset&gt;
  538. &lt;/ftp&gt;
  539. </pre>
  540. <p>If apache.org ever switches to a unix FTP server that uses the new all-numeric
  541. format for timestamps, this version would become necessary. It would accomplish
  542. the same functionality as the previous example but would successfully handle the
  543. numeric timestamps.
  544. The <code>systemTypeKey</code> is not necessary here but helps clarify what is
  545. going on.</p>
  546. <pre>
  547. &lt;ftp action="get"
  548. server="ftp.hypthetical.fr"
  549. userid="anonymous"
  550. password="me@myorg.com"
  551. defaultDateFormatConfig="d MMM yyyy"
  552. recentDateFormatConfig="d MMM HH:mm"
  553. serverLanguageCodeConfig="fr"&gt;
  554. &lt;fileset dir="htdocs/manual"&gt;
  555. &lt;include name="**/*.html"/&gt;
  556. &lt;/fileset&gt;
  557. &lt;/ftp&gt;
  558. </pre>
  559. <p>Logs into a UNIX FTP server at <code>ftp.hypothetical.fr</code> which displays
  560. dates with French names in Standard European format, as <code>anonymous</code>, and
  561. recursively downloads all .html files from default directory for that user
  562. into the <code>htdocs/manual</code> directory on the local machine.</p>
  563. <h3>Deleting Files</h3>
  564. As you've probably guessed by now, you use nested fileset elements to
  565. select the files to delete from the remote FTP server. Again, the
  566. filesets are relative to the remote directory, not a local directory. In
  567. fact, the dir attribute of the fileset is ignored completely.
  568. <pre>
  569. &lt;ftp action="del"
  570. server="ftp.apache.org"
  571. userid="anonymous"
  572. password="me@myorg.com"&gt;
  573. &lt;fileset&gt;
  574. &lt;include name="**/*.tmp"/&gt;
  575. &lt;/fileset&gt;
  576. &lt;/ftp&gt;
  577. </pre>
  578. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  579. tries to delete all *.tmp files from the default directory for that user.
  580. If you don't have permission to delete a file, a BuildException is thrown.</p>
  581. <h3>Listing Files</h3>
  582. <pre>
  583. &lt;ftp action="list"
  584. server="ftp.apache.org"
  585. userid="anonymous"
  586. password="me@myorg.com"
  587. listing="data/ftp.listing"&gt;
  588. &lt;fileset&gt;
  589. &lt;include name="**"/&gt;
  590. &lt;/fileset&gt;
  591. &lt;/ftp&gt;
  592. </pre>
  593. <p>This provides a file listing in <code>data/ftp.listing</code> of all the files on
  594. the FTP server relative to the default directory of the <code>anonymous</code>
  595. user. The listing is in whatever format the FTP server normally lists files.</p>
  596. <h3>Creating Directories</h3>
  597. <p>Note that with the mkdir action, the directory to create is specified using the
  598. remotedir attribute.</p>
  599. <pre>
  600. &lt;ftp action="mkdir"
  601. server="ftp.apache.org"
  602. userid="anonymous"
  603. password="me@myorg.com"
  604. remotedir="some/remote/dir"/&gt;
  605. </pre>
  606. <p>This creates the directory <code>some/remote/dir</code> beneath the default root
  607. directory. As with all other actions, the directory separator character must be correct
  608. according to the desires of the FTP server.</p>
  609. <h3>Removing Directories</h3>
  610. This action uses nested fileset elements to
  611. select the directories to remove from the remote FTP server. The
  612. filesets are relative to the remote directory, not a local directory.
  613. The dir attribute of the fileset is ignored completely.
  614. The directories to be removed must be empty, or contain only
  615. other directories that have been also selected to be removed by the filesets
  616. patterns, otherwise a BuildException will be thrown.
  617. Also, if you don't have permission to remove a directory, a BuildException is
  618. thrown.
  619. <pre>
  620. &lt;ftp action="rmdir"
  621. server="ftp.apache.org"
  622. userid="anonymous"
  623. password="me@myorg.com"
  624. remotedir="/somedir" &gt;
  625. &lt;fileset&gt;
  626. &lt;include name="dira"/&gt;
  627. &lt;include name="dirb/**"/&gt;
  628. &lt;/fileset&gt;
  629. &lt;/ftp&gt;
  630. </pre>
  631. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  632. tries to remove <code>/somedir/dira</code> directory and
  633. all the directories tree starting at, and including, <code>/somedir/dirb</code>.
  634. When removing the <code>/somedir/dirb</code> tree,
  635. it will start at the leaves moving up to the root, so that when
  636. it tries to remove a directory it is sure all the directories under it are
  637. already removed.
  638. Obviously all the files in the tree must have been already deleted.
  639. </p>
  640. <p>As an example suppose you want to delete everything contained into
  641. <code>/somedir</code>, so invoke first the <code>&lt;ftp&gt;</code> task with
  642. <code>action="delete"</code>, then with
  643. <code>action="rmdir"</code> specifying in both cases
  644. <code>remotedir="/somedir"</code> and
  645. <pre>
  646. &lt;fileset&gt;
  647. &lt;include name="**"/&gt;
  648. &lt;/fileset&gt;
  649. </pre>
  650. The directory specified in the <code>remotedir</code> parameter is never
  651. selected for remove, so if you need to remove it, specify its parent in
  652. <code>remotedir</code> parameter and include it in the
  653. <code>&lt;fileset&gt;</code> pattern, like <code>"somedir/**"</code>.
  654. </p>
  655. <hr>
  656. <p align="center">Copyright &copy; 2000-2005 The Apache Software Foundation. All rights
  657. Reserved.</p>
  658. </body>
  659. </html>