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

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