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 24 KiB

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