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 27 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  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 colspan="3">
  194. <p><b>The following attributes require <a href=
  195. "http://jakarta.apache.org/commons/net/download.html">
  196. jakarta-commons-net-1.4.0 or greater</a>.</b></p>
  197. <p>
  198. Use these options when the standard options don't work, because
  199. <ul><li>the server is in a different timezone and you need timestamp
  200. dependency checking</li>
  201. <li>the default timestamp formatting doesn't match the server display and
  202. list parsing therefore fails</li></ul>
  203. </p><p>
  204. If none of these is specified, the default mechanism of letting the system
  205. auto-detect the server OS type based on the FTP SYST command and assuming
  206. standard formatting for that OS type will be used.
  207. </p><p>
  208. To aid in property-file-based development where a build script is configured
  209. with property files, for any of these attributes, a value of <code>""</code>
  210. is equivalent to not specifying it.
  211. </p><p>
  212. Please understand that these options are incompatible with the autodetection
  213. scheme. If any of these options is specified, (other than with a value of
  214. <code>""</code> ) a system type must be chosen and if systemTypeKey is not
  215. specified, UNIX will be assumed. The philosophy behind this is that these
  216. options are for setting non-standard formats, and a build-script author who
  217. knows what system he is dealing with will know what options to need to be
  218. set. Otherwise, these options should be left alone and the default
  219. autodetection scheme can be used and will work in the majority of cases.
  220. </p></td>
  221. </tr>
  222. <tr>
  223. <td valign="top">systemTypeKey</td>
  224. <td valign="top">Specifies the type of system in use on the server.
  225. Supported values are <code>"UNIX", "VMS", "WINDOWS", "OS/2", "OS/400",
  226. "MVS".</code> If not specified, (or specified as <code>""</code>) and if
  227. no other xxxConfig attributes are specified, the autodectection mechanism
  228. based on the FTP SYST command will be used.<br>
  229. Since ant 1.7
  230. </td>
  231. <td valign="top" align="center">No, but if any of the following xxxConfig
  232. attributes is specified, UNIX will be assumed, even if <code>""</code>
  233. is specified here.
  234. </td>
  235. </tr>
  236. <tr>
  237. <td valign="top">serverTimeZoneConfig</td>
  238. <td valign="top">Specify as a Java
  239. <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/TimeZone.html">
  240. TimeZone</a> identifier, (e.g. <code>GMT</code>, <code>America/Chicago</code> or
  241. <code>Asia/Jakarta</code>) the timezone used by the server for timestamps. This
  242. enables timestamp dependency checking even when the server is in a different
  243. time zone from the client. Time Zones know, also, about daylight savings time,
  244. and do not require you to calculate milliseconds of difference. If not specified,
  245. (or specified as <code>""</code>), the time zone of the client is assumed.<br>
  246. Since ant 1.7
  247. </td>
  248. <td valign="top" align="center">No</td>
  249. </tr>
  250. <tr>
  251. <td valign="top">defaultDateFormatConfig</td>
  252. <td valign="top">Specify in Java
  253. <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html">
  254. SimpleDateFormat</a> notation, (e.g.
  255. <code>yyyy-MM-dd</code>), the date format generally used by the FTP server
  256. to parse dates. In some cases this will be the only date format used.
  257. In others, (unix for example) this will be used for dates
  258. older than a year old. (See <b>recentDateFormatConfig</b>). If not specified,
  259. (or specified as <code>""</code>), the default date format for the system
  260. type indicated by the <b>systemTypeKey</b> attribute will be used.<br>
  261. Since ant 1.7
  262. </td>
  263. <td valign="top" align="center">
  264. No.
  265. </td>
  266. </tr>
  267. <tr>
  268. <td valign="top">recentDateFormatConfig</td>
  269. <td valign="top">Specify in Java
  270. <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html">
  271. SimpleDateFormat</a> notation,
  272. (e.g. <code>MMM dd hh:mm</code>) the date format used by the FTP server
  273. to parse dates less than a year old. If not specified (or specified as
  274. <code>""</code>), and if the system type indicated by the system key uses
  275. a recent date format, its standard format will be used.<br>
  276. Since ant 1.7
  277. </td>
  278. <td valign="top" align="center">No</td>
  279. </tr>
  280. <tr>
  281. <td valign="top">serverLanguageCodeConfig</td>
  282. <td valign="top">a <a href="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt">
  283. two-letter ISO-639 language code</a> used to specify the
  284. language used by the server to format month names. This only needs to be
  285. specified when the server uses non-numeric abbreviations for months in its
  286. date listings in a language other than English. This appears to be
  287. becoming rarer and rarer, as commonly distributed ftp servers seem
  288. increasingly to use English or all-numeric formats.
  289. Languages supported are:
  290. <ul>
  291. <li>en - English</li>
  292. <li>fr - French</li>
  293. <li>de - German</li>
  294. <li>it - Italian</li>
  295. <li>es - Spanish</li>
  296. <li>pt - Portuguese</li>
  297. <li>da - Danish</li>
  298. <li>sv - Swedish</li>
  299. <li>no - Norwegian</li>
  300. <li>nl - Dutch</li>
  301. <li>ro - Romanian</li>
  302. <li>sq - Albanian</li>
  303. <li>sh - Serbo-croatian</li>
  304. <li>sk - Slovak</li>
  305. <li>sl - Slovenian</li>
  306. </ul>
  307. If you require a language other than the above, see also the
  308. <b>shortMonthNamesConfig</b> attribute.<br>
  309. Since ant 1.7
  310. </td>
  311. <td valign="top" align="center">No</td>
  312. </tr>
  313. <tr>
  314. <td valign="top">shortMonthNamesConfig</td>
  315. <td valign="top">specify the month abbreviations used on the server in file
  316. timestamp dates as a pipe-delimited string for each month. For example,
  317. a set of month names used by a hypothetical
  318. Icelandic FTP server might conceivably be specified as
  319. <code>"jan|feb|mar|apr|ma&#xED;|j&#xFA;n|j&#xFA;l|&#xE1;g&#xFA;|sep|okt|n&#xF3;v|des"</code>.
  320. This attribute exists primarily to support languages not supported by
  321. the <b>serverLanguageCode</b> attribute.<br>
  322. Since ant 1.7
  323. </td>
  324. <td valign="top" align="center">No</td>
  325. </tr>
  326. </table>
  327. <h3>Note about remotedir attribute</h3>
  328. <table border="1" cellpadding="2" cellspacing="0"
  329. >
  330. <tbody>
  331. <tr>
  332. <td style="vertical-align: top;" width="20%">Action<br>
  333. </td>
  334. <td style="vertical-align: top;" width="40%">meaning of <code>remotedir</code><br>
  335. </td>
  336. <td style="vertical-align: top;">use of nested <code>fileset</code>
  337. (s)<br>
  338. </td>
  339. </tr>
  340. <tr>
  341. <td style="vertical-align: top;" width="20%">send/put<br>
  342. </td>
  343. <td style="vertical-align: top;" width="40%">base directory to
  344. which the files are sent<br>
  345. </td>
  346. <td style="vertical-align: top;">they are used normally and
  347. evaluated on the local machine<br>
  348. </td>
  349. </tr>
  350. <tr>
  351. <td style="vertical-align: top;" width="20%">recv/get<br>
  352. </td>
  353. <td style="vertical-align: top;" width="40%">base directory from
  354. which the files are retrieved<br>
  355. </td>
  356. <td style="vertical-align: top;">the remote files located under
  357. the <code>remotedir </code>matching the include/exclude patterns of
  358. the <code>fileset&nbsp;</code></td>
  359. </tr>
  360. <tr>
  361. <td style="vertical-align: top;" width="20%">del/delete<br>
  362. </td>
  363. <td style="vertical-align: top;" width="40%">base directory from
  364. which files get deleted<br>
  365. </td>
  366. <td style="vertical-align: top;">the remote files located under
  367. the <code>remotedir </code>matching the include/exclude patterns of
  368. the <code>fileset <br>
  369. </code></td>
  370. </tr>
  371. <tr>
  372. <td style="vertical-align: top;" width="20%">list<br>
  373. </td>
  374. <td style="vertical-align: top;" width="40%">base directory from
  375. which files are listed<br>
  376. </td>
  377. <td style="vertical-align: top;">the remote files located under
  378. the <code>remotedir </code>matching the include/exclude patterns of
  379. the <code>fileset <br>
  380. </code></td>
  381. </tr>
  382. <tr>
  383. <td style="vertical-align: top;" width="20%">mkdir</td>
  384. <td style="vertical-align: top;" width="40%">directory to create<br>
  385. </td>
  386. <td style="vertical-align: top;">not used<br>
  387. </td>
  388. </tr>
  389. <tr>
  390. <td style="vertical-align: top;" width="20%">chmod</td>
  391. <td style="vertical-align: top;" width="40%">base directory from
  392. which the mode of files get changed<br>
  393. </td>
  394. <td style="vertical-align: top;">the remote files located under
  395. the <code>remotedir </code>matching the include/exclude patterns of
  396. the <code>fileset <br>
  397. </code></td>
  398. </tr>
  399. <tr>
  400. <td style="vertical-align: top;" width="20%">rmdir<br>
  401. </td>
  402. <td style="vertical-align: top;" width="40%">base directory from
  403. which directories get removed<br>
  404. </td>
  405. <td style="vertical-align: top;">the remote directories located
  406. under the <code>remotedir </code>matching the include/exclude
  407. patterns of the <code>fileset <br>
  408. </code></td>
  409. </tr>
  410. </tbody>
  411. </table><h3>Parameters specified as nested elements</h3>
  412. <h4>fileset</h4>
  413. <p>The ftp task supports any number of nested <a
  414. href="../CoreTypes/fileset.html"><code>&lt;fileset&gt;</code></a> elements to specify
  415. the files to be retrieved, or deleted, or listed, or whose mode you want to change.</p>
  416. <p>
  417. The attribute <code>followsymlinks</code> of <code>fileset</code> is supported on
  418. local (put) as well as remote (get, chmod, delete) filesets.
  419. <em>Before ant 1.6 there was no support of symbolic links in remote filesets.
  420. In order to exclude symbolic links (preserve the behavior of ant 1.5.x and older),
  421. you need to explicitly set <code>followsymlinks</code> to <code>false</code>.</em>
  422. On remote filesets hidden files are not checked for being symbolic links. Hidden
  423. files are currently assumed to not be symbolic links.
  424. </p>
  425. <p>
  426. Remote filesets do not support selectors.<br>
  427. </p>
  428. <h3>Sending Files</h3>
  429. <p>The easiest way to describe how to send files is with a couple of examples:</p>
  430. <pre>
  431. &lt;ftp server="ftp.apache.org"
  432. userid="anonymous"
  433. password="me@myorg.com"&gt;
  434. &lt;fileset dir="htdocs/manual"/&gt;
  435. &lt;/ftp&gt;
  436. </pre>
  437. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  438. uploads all files in the <code>htdocs/manual</code> directory
  439. to the default directory for that user.</p>
  440. <pre> &lt;ftp server="ftp.apache.org"
  441. remotedir="incoming"
  442. userid="anonymous"
  443. password="me@myorg.com"
  444. depends="yes"&gt;
  445. &lt;fileset dir="htdocs/manual"/&gt;
  446. &lt;/ftp&gt;</pre>
  447. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  448. uploads all new or changed files in the <code>htdocs/manual</code> directory
  449. to the <code>incoming</code> directory relative to the default directory
  450. for <code>anonymous</code>.</p>
  451. <pre> &lt;ftp server="ftp.apache.org"
  452. port="2121"
  453. remotedir="/pub/incoming"
  454. userid="coder"
  455. password="java1"
  456. passive="yes"
  457. depends="yes"
  458. binary="no"&gt;
  459. &lt;fileset dir="htdocs/manual"&gt;
  460. &lt;include name="**/*.html"/&gt;
  461. &lt;/fileset&gt;
  462. &lt;/ftp&gt;</pre>
  463. <p>Logs in to <code>ftp.apache.org</code> at port <code>2121</code> as
  464. <code>coder</code> with password <code>java1</code> and uploads all new or
  465. changed HTML files in the <code>htdocs/manual</code> directory to the
  466. <code>/pub/incoming</code> directory. The files are transferred in text mode.
  467. Passive mode has been switched on to send files from behind a firewall.</p>
  468. <pre> &lt;ftp server="ftp.hypothetical.india.org"
  469. port="2121"
  470. remotedir="/pub/incoming"
  471. userid="coder"
  472. password="java1"
  473. depends="yes"
  474. binary="no"
  475. systemTypeKey="Windows"
  476. serverTimeZoneConfig="India/Calcutta"&gt;
  477. &lt;fileset dir="htdocs/manual"&gt;
  478. &lt;include name="**/*.html"/&gt;
  479. &lt;/fileset&gt;
  480. &lt;/ftp&gt;</pre>
  481. <p>Logs in to a Windows server at <code>ftp.hypothetical.india.org</code>
  482. at port <code>2121</code> as <code>coder</code> with password <code>java1</code>
  483. and uploads all new or changed (accounting for timezone differences)
  484. HTML files in the <code>htdocs/manual</code>
  485. directory to the <code>/pub/incoming</code> directory. The files are transferred
  486. in text mode.</p>
  487. <pre> &lt;ftp server="ftp.nt.org"
  488. remotedir="c:\uploads"
  489. userid="coder"
  490. password="java1"
  491. separator="\"
  492. verbose="yes"&gt;
  493. &lt;fileset dir="htdocs/manual"&gt;
  494. &lt;include name="**/*.html"/&gt;
  495. &lt;/fileset&gt;
  496. &lt;/ftp&gt;</pre><p>Logs in to the Windows-based <code>ftp.nt.org</code> as
  497. <code>coder</code> with password <code>java1</code> and uploads all
  498. HTML files in the <code>htdocs/manual</code> directory to the
  499. <code>c:\uploads</code> directory. Progress messages are displayed as each
  500. file is uploaded.</p>
  501. <h3>Getting Files</h3>
  502. <p>Getting files from an FTP server works pretty much the same way as
  503. sending them does. The only difference is that the nested filesets
  504. use the remotedir attribute as the base directory for the files on the
  505. FTP server, and the dir attribute as the local directory to put the files
  506. into. The file structure from the FTP site is preserved on the local machine.</p>
  507. <pre>
  508. &lt;ftp action="get"
  509. server="ftp.apache.org"
  510. userid="anonymous"
  511. password="me@myorg.com"&gt;
  512. &lt;fileset dir="htdocs/manual"&gt;
  513. &lt;include name="**/*.html"/&gt;
  514. &lt;/fileset&gt;
  515. &lt;/ftp&gt;
  516. </pre>
  517. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  518. recursively downloads all .html files from default directory for that user
  519. into the <code>htdocs/manual</code> directory on the local machine.</p>
  520. <pre>
  521. &lt;ftp action="get"
  522. server="ftp.apache.org"
  523. userid="anonymous"
  524. password="me@myorg.com"
  525. systemTypeKey="UNIX"
  526. defaultDateFormatConfig="yyyy-MM-dd HH:mm"&gt;
  527. &lt;fileset dir="htdocs/manual"&gt;
  528. &lt;include name="**/*.html"/&gt;
  529. &lt;/fileset&gt;
  530. &lt;/ftp&gt;
  531. </pre>
  532. <p>If apache.org ever switches to a unix FTP server that uses the new all-numeric
  533. format for timestamps, this version would become necessary. It would accomplish
  534. the same functionality as the previous example but would successfully handle the
  535. numeric timestamps.
  536. The <code>systemTypeKey</code> is not necessary here but helps clarify what is
  537. going on.</p>
  538. <pre>
  539. &lt;ftp action="get"
  540. server="ftp.hypthetical.fr"
  541. userid="anonymous"
  542. password="me@myorg.com"
  543. defaultDateFormatConfig="d MMM yyyy"
  544. recentDateFormatConfig="d MMM HH:mm"
  545. serverLanguageCodeConfig="fr"&gt;
  546. &lt;fileset dir="htdocs/manual"&gt;
  547. &lt;include name="**/*.html"/&gt;
  548. &lt;/fileset&gt;
  549. &lt;/ftp&gt;
  550. </pre>
  551. <p>Logs into a UNIX FTP server at <code>ftp.hypothetical.fr</code> which displays
  552. dates with French names in Standard European format, as <code>anonymous</code>, and
  553. recursively downloads all .html files from default directory for that user
  554. into the <code>htdocs/manual</code> directory on the local machine.</p>
  555. <h3>Deleting Files</h3>
  556. As you've probably guessed by now, you use nested fileset elements to
  557. select the files to delete from the remote FTP server. Again, the
  558. filesets are relative to the remote directory, not a local directory. In
  559. fact, the dir attribute of the fileset is ignored completely.
  560. <pre>
  561. &lt;ftp action="del"
  562. server="ftp.apache.org"
  563. userid="anonymous"
  564. password="me@myorg.com"&gt;
  565. &lt;fileset&gt;
  566. &lt;include name="**/*.tmp"/&gt;
  567. &lt;/fileset&gt;
  568. &lt;/ftp&gt;
  569. </pre>
  570. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  571. tries to delete all *.tmp files from the default directory for that user.
  572. If you don't have permission to delete a file, a BuildException is thrown.</p>
  573. <h3>Listing Files</h3>
  574. <pre>
  575. &lt;ftp action="list"
  576. server="ftp.apache.org"
  577. userid="anonymous"
  578. password="me@myorg.com"
  579. listing="data/ftp.listing"&gt;
  580. &lt;fileset&gt;
  581. &lt;include name="**"/&gt;
  582. &lt;/fileset&gt;
  583. &lt;/ftp&gt;
  584. </pre>
  585. <p>This provides a file listing in <code>data/ftp.listing</code> of all the files on
  586. the FTP server relative to the default directory of the <code>anonymous</code>
  587. user. The listing is in whatever format the FTP server normally lists files.</p>
  588. <h3>Creating Directories</h3>
  589. <p>Note that with the mkdir action, the directory to create is specified using the
  590. remotedir attribute.</p>
  591. <pre>
  592. &lt;ftp action="mkdir"
  593. server="ftp.apache.org"
  594. userid="anonymous"
  595. password="me@myorg.com"
  596. remotedir="some/remote/dir"/&gt;
  597. </pre>
  598. <p>This creates the directory <code>some/remote/dir</code> beneath the default root
  599. directory. As with all other actions, the directory separator character must be correct
  600. according to the desires of the FTP server.</p>
  601. <h3>Removing Directories</h3>
  602. This action uses nested fileset elements to
  603. select the directories to remove from the remote FTP server. The
  604. filesets are relative to the remote directory, not a local directory.
  605. The dir attribute of the fileset is ignored completely.
  606. The directories to be removed must be empty, or contain only
  607. other directories that have been also selected to be removed by the filesets
  608. patterns, otherwise a BuildException will be thrown.
  609. Also, if you don't have permission to remove a directory, a BuildException is
  610. thrown.
  611. <pre>
  612. &lt;ftp action="rmdir"
  613. server="ftp.apache.org"
  614. userid="anonymous"
  615. password="me@myorg.com"
  616. remotedir="/somedir" &gt;
  617. &lt;fileset&gt;
  618. &lt;include name="dira"/&gt;
  619. &lt;include name="dirb/**"/&gt;
  620. &lt;/fileset&gt;
  621. &lt;/ftp&gt;
  622. </pre>
  623. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  624. tries to remove <code>/somedir/dira</code> directory and
  625. all the directories tree starting at, and including, <code>/somedir/dirb</code>.
  626. When removing the <code>/somedir/dirb</code> tree,
  627. it will start at the leaves moving up to the root, so that when
  628. it tries to remove a directory it is sure all the directories under it are
  629. already removed.
  630. Obviously all the files in the tree must have been already deleted.
  631. </p>
  632. <p>As an example suppose you want to delete everything contained into
  633. <code>/somedir</code>, so invoke first the <code>&lt;ftp&gt;</code> task with
  634. <code>action="delete"</code>, then with
  635. <code>action="rmdir"</code> specifying in both cases
  636. <code>remotedir="/somedir"</code> and
  637. <pre>
  638. &lt;fileset&gt;
  639. &lt;include name="**"/&gt;
  640. &lt;/fileset&gt;
  641. </pre>
  642. The directory specified in the <code>remotedir</code> parameter is never
  643. selected for remove, so if you need to remove it, specify its parent in
  644. <code>remotedir</code> parameter and include it in the
  645. <code>&lt;fileset&gt;</code> pattern, like <code>"somedir/**"</code>.
  646. </p>
  647. <hr>
  648. <p align="center">Copyright &copy; 2000-2005 The Apache Software Foundation. All rights
  649. Reserved.</p>
  650. </body>
  651. </html>