![]()
|
FTPDescriptionThe ftp task implements a basic FTP client that can send, receive, list, delete files, and create directories. See below for descriptions and examples of how to perform each task. Note: This task depends on external libraries not included in the Ant distribution. See Library Dependencies for more information. The ftp task makes no attempt to determine what file system syntax is required by the remote server, and defaults to Unix standards. remotedir must be specified in the exact syntax required by the ftp server. If the usual Unix conventions are not supported by the server, separator can be used to set the file separator that should be used instead. See the section on directory based tasks, on how the inclusion/exclusion of files works, and how to write patterns. Warning: for the get and delete actions to work properly with a Windows 2000 ftp server, it needs to be configured to generate Unix style listings, and not the default MS-DOS listing. Or someone needs to write the code to parse MS-DOS listings -any takers? Parameters
Sending FilesThe easiest way to describe how to send files is with a couple of examples: <ftp server="ftp.apache.org" userid="anonymous" password="me@myorg.com"> <fileset dir="htdocs/manual"/> </ftp> Logs in to <ftp server="ftp.apache.org" remotedir="incoming" userid="anonymous" password="me@myorg.com" depends="yes" > <fileset dir="htdocs/manual"/> </ftp> Logs in to <ftp server="ftp.apache.org" port="2121" remotedir="/pub/incoming" userid="coder" password="java1" depends="yes" binary="no" > <fileset dir="htdocs/manual"> <include name="**/*.html"/> </fileset> </ftp> Logs in to <ftp server="ftp.nt.org" remotedir="c:\uploads" userid="coder" password="java1" separator="\" verbose="yes" > <fileset dir="htdocs/manual"> <include name="**/*.html"/> </fileset> </ftp> Logs in to the Windows-based Getting FilesGetting files from an FTP server works pretty much the same way as sending them does. The only difference is that the nested filesets use the remotedir attribute as the base directory for the files on the FTP server, and the dir attribute as the local directory to put the files into. The file structure from the FTP site is preserved on the local machine. <ftp action="get" server="ftp.apache.org" userid="anonymous" password="me@myorg.com"> <fileset dir="htdocs/manual"> <include name="**/*.html"/> </fileset> </ftp> Logs in to Deleting FilesAs you've probably guessed by now, you use nested fileset elements to select the files to delete from the remote FTP server. Again, the filesets are relative to the remote directory, not a local directory. In fact, the dir attribute of the fileset is ignored completely.<ftp action="del" server="ftp.apache.org" userid="anonymous" password="me@myorg.com"> <fileset> <include name="**/*.tmp"/> </fileset> </ftp> Logs in to Listing Files<ftp action="list" server="ftp.apache.org" userid="anonymous" password="me@myorg.com" listing="data/ftp.listing"> <fileset> <include name="**"/> </fileset> </ftp> This provides a file listing in Creating DirectoriesNote that with the mkdir action, the directory to create is specified using the remotedir attribute. <ftp action="mkdir" server="ftp.apache.org" userid="anonymous" password="me@myorg.com" remotedir="some/remote/dir"/> This creates the directory Copyright © 2000-2002 Apache Software Foundation. All rights Reserved. |