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

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