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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Ant User Manual</title>
  5. </head>
  6. <body>
  7. <h2><a name="ftp">FTP</a></h2>
  8. <h3>Description</h3>
  9. <p><b>Note:</b> The ftp-task uses the NetComponents-Package which you will need to download from
  10. <a href="http://www.savarese.org" target="_top">http://www.savarese.org</a> and add to your classpath.</p>
  11. <p>The ftp task implements a basic FTP client that can send, receive,
  12. list, and delete files. See below for descriptions and examples of how
  13. to perform each task.</p>
  14. <p>The ftp task makes no attempt to determine what file system syntax is
  15. required by the remote server, and defaults to Unix standards.
  16. <i>remotedir</i> must be specified in the exact syntax required by the ftp
  17. server. If the usual Unix conventions are not supported by the server,
  18. <i>separator</i> can be used to set the file separator that should be used
  19. instead.</p>
  20. <p>See the section on <a href="../dirtasks.html#directorybasedtasks">directory based
  21. tasks</a>, on how the inclusion/exclusion of files works, and how to
  22. write patterns.</p>
  23. <h3>Parameters</h3>
  24. <table border="1" cellpadding="2" cellspacing="0">
  25. <tr>
  26. <td valign="top"><b>Attribute</b></td>
  27. <td valign="top"><b>Description</b></td>
  28. <td align="center" valign="top"><b>Required</b></td>
  29. </tr>
  30. <tr>
  31. <td valign="top">server</td>
  32. <td valign="top">the address of the remote ftp server.</td>
  33. <td valign="top" align="center">Yes</td>
  34. </tr>
  35. <tr>
  36. <td valign="top">port</td>
  37. <td valign="top">the port number of the remote ftp server.
  38. Defaults to port 21.</td>
  39. <td valign="top" align="center">No</td>
  40. </tr>
  41. <tr>
  42. <td valign="top">userid</td>
  43. <td valign="top">the login id to use on the ftp server.</td>
  44. <td valign="top" align="center">Yes</td>
  45. </tr>
  46. <tr>
  47. <td valign="top">password</td>
  48. <td valign="top">the login password to use on the ftp server.</td>
  49. <td valign="top" align="center">Yes</td>
  50. </tr>
  51. <tr>
  52. <td valign="top">remotedir</td>
  53. <td valign="top">the directory to which to upload files on the
  54. ftp server.</td>
  55. <td valign="top" align="center">No</td>
  56. </tr>
  57. <tr>
  58. <td valign="top">action</td>
  59. <td valign="top">the ftp action to perform, defaulting to &quot;send&quot;.
  60. Currently supports &quot;put&quot;, &quot;get&quot;,
  61. &quot;del&quot;, and &quot;list&quot;.</td>
  62. <td valign="top" align="center">No</td>
  63. </tr>
  64. <tr>
  65. <td valign="top">binary</td>
  66. <td valign="top">selects binary-mode (&quot;yes&quot;) or text-mode
  67. (&quot;no&quot;) transfers.
  68. Defaults to &quot;yes&quot;</td>
  69. <td valign="top" align="center">No</td>
  70. </tr>
  71. <tr>
  72. <td valign="top">passive</td>
  73. <td valign="top">selects passive-mode (&quot;yes&quot;) transfers.
  74. Defaults to &quot;no&quot;</td>
  75. <td valign="top" align="center">No</td>
  76. </tr>
  77. <tr>
  78. <td valign="top">verbose</td>
  79. <td valign="top">displays information on each file transferred if set
  80. to &quot;yes&quot;. Defaults to &quot;no&quot;.</td>
  81. <td valign="top" align="center">No</td>
  82. </tr>
  83. <tr>
  84. <td valign="top">depends</td>
  85. <td valign="top">transfers only new or changed files if set to
  86. &quot;yes&quot;. Defaults to &quot;no&quot;.</td>
  87. <td valign="top" align="center">No</td>
  88. </tr>
  89. <tr>
  90. <td valign="top">newer</td>
  91. <td valign="top">a synonym for <i>depends</i>.</td>
  92. <td valign="top" align="center">No</td>
  93. </tr>
  94. <tr>
  95. <td valign="top">separator</td>
  96. <td valign="top">sets the file separator used on the ftp server.
  97. Defaults to &quot;/&quot;.</td>
  98. <td valign="top" align="center">No</td>
  99. </tr>
  100. <tr>
  101. <td valign="top">listing</td>
  102. <td valign="top">the file to write results of the &quot;list&quot; action.
  103. Required for the &quot;list&quot; action, ignored otherwise.</td>
  104. <td valign="top" align="center">No</td>
  105. </tr>
  106. </table>
  107. <h3>Sending Files</h3>
  108. <p>The easiest way to describe how to send files is with a couple of examples:</p>
  109. <pre>
  110. &lt;ftp server=&quot;ftp.apache.org&quot;
  111. userid=&quot;anonymous&quot;
  112. password=&quot;me@myorg.com&quot;&gt;
  113. &lt;fileset dir=&quot;htdocs/manual&quot;/&gt;
  114. &lt;/ftp&gt;
  115. </pre>
  116. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  117. uploads all files in the <code>htdocs/manual</code> directory
  118. to the default directory for that user.</p>
  119. <pre> &lt;ftp server=&quot;ftp.apache.org&quot;
  120. remotedir=&quot;incoming&quot;
  121. userid=&quot;anonymous&quot;
  122. password=&quot;me@myorg.com&quot;
  123. depends=&quot;yes&quot;
  124. &gt;
  125. &lt;fileset dir=&quot;htdocs/manual&quot;/&gt;
  126. &lt;/ftp&gt;</pre>
  127. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  128. uploads all new or changed files in the <code>htdocs/manual</code> directory
  129. to the <code>incoming</code> directory relative to the default directory
  130. for <code>anonymous</code>.</p>
  131. <pre> &lt;ftp server=&quot;ftp.apache.org&quot;
  132. port=&quot;2121&quot;
  133. remotedir=&quot;/pub/incoming&quot;
  134. userid=&quot;coder&quot;
  135. password=&quot;java1&quot;
  136. depends=&quot;yes&quot;
  137. binary=&quot;no&quot;
  138. &gt;
  139. &lt;fileset dir=&quot;htdocs/manual&quot;&gt;
  140. &lt;include name=&quot;**/*.html&quot;/&gt;
  141. &lt;/fileset&gt;
  142. &lt;/ftp&gt;</pre>
  143. <p>Logs in to <code>ftp.apache.org</code> at port <code>2121</code> as
  144. <code>coder</code> with password <code>java1</code> and uploads all new or
  145. changed HTML files in the <code>htdocs/manual</code> directory to the
  146. <code>/pub/incoming</code> directory. The files are transferred in text mode. Passive mode has been switched on to send files from behind a firewall.</p>
  147. <pre> &lt;ftp server=&quot;ftp.nt.org&quot;
  148. remotedir=&quot;c:\uploads&quot;
  149. userid=&quot;coder&quot;
  150. password=&quot;java1&quot;
  151. separator=&quot;\&quot;
  152. verbose=&quot;yes&quot;</pre>
  153. <PRE>
  154. &gt;
  155. &lt;fileset dir=&quot;htdocs/manual&quot;&gt;
  156. &lt;include name=&quot;**/*.html&quot;/&gt;
  157. &lt;/fileset&gt;
  158. &lt;/ftp&gt;</PRE><p>Logs in to the Windows-based <code>ftp.nt.org</code> as
  159. <code>coder</code> with password <code>java1</code> and uploads all
  160. HTML files in the <code>htdocs/manual</code> directory to the
  161. <code>c:\uploads</code> directory. Progress messages are displayed as each
  162. file is uploaded.</p>
  163. <h3>Getting Files</h3>
  164. <p>Getting files from an FTP server works pretty much the same way as
  165. sending them does. The only difference is that the nested filesets
  166. use the remotedir attribute as the base directory for the files on the
  167. FTP server, and the dir attribute as the local directory to put the files
  168. into. The file structure from the FTP site is preserved on the local machine.</p>
  169. <pre>
  170. &lt;ftp action=&quot;get&quot;
  171. server=&quot;ftp.apache.org&quot;
  172. userid=&quot;anonymous&quot;
  173. password=&quot;me@myorg.com&quot;&gt;
  174. &lt;fileset dir=&quot;htdocs/manual&quot; &gt;
  175. &lt;include name=&quot;**/*.html&quot;/&gt;
  176. &lt;/fileset&gt;
  177. &lt;/ftp&gt;
  178. </pre>
  179. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  180. recursively downloads all .html files from default directory for that user
  181. into the <code>htdocs/manual</code> directory on the local machine.</p>
  182. <h3>Deleting Files</h3>
  183. As you've probably guessed by now, you use nested fileset elements to
  184. select the files to delete from the remote FTP server. Again, the
  185. filesets are relative to the remote directory, not a local directory. In
  186. fact, the dir attribute of the fileset is ignored completely.
  187. <pre>
  188. &lt;ftp action=&quot;del&quot;
  189. server=&quot;ftp.apache.org&quot;
  190. userid=&quot;anonymous&quot;
  191. password=&quot;me@myorg.com&quot; &gt;
  192. &lt;fileset&gt;
  193. &lt;include name=&quot;**/*.tmp&quot;/&gt;
  194. &lt;/fileset&gt;
  195. &lt;/ftp&gt;
  196. </pre>
  197. <p>Logs in to <code>ftp.apache.org</code> as <code>anonymous</code> and
  198. tries to delete all *.tmp files from the default directory for that user.
  199. If you don't have permission to delete a file, a BuildException is thrown.</p>
  200. <h3>Listing Files</h3>
  201. <pre>
  202. &lt;ftp action=&quot;list&quot;
  203. server=&quot;ftp.apache.org&quot;
  204. userid=quot;anonymous&quot;
  205. password=&quot;me@myorg.com&quot;
  206. listing=&quot;data/ftp.listing&quot; &gt;
  207. &lt;fileset&gt;
  208. &lt;include name=&quot;**&quot;/&gt;
  209. &lt;/fileset&gt;
  210. &lt;/ftp&gt;
  211. </pre>
  212. <p>This provides a file listing in <code>data/ftp.listing</code> of all the files on
  213. the FTP server relative to the default directory of the <code>anonymous</code>
  214. user. The listing is in whatever format the FTP server normally lists files.</p>
  215. <hr>
  216. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  217. Reserved.</p>
  218. </body>
  219. </html>