The 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.
ftp タスクでは、 ファイル送信、取得、ファイル一覧、ファイル削除、ディレクトリ作成の可能な、 基本的な ftp クライアントを実装しています。 それぞれのタスクの実行方法は後述の説明と、例をご覧ください。
Note: This task depends on external libraries not included in the Ant distribution. See Library Dependencies for more information.
メモ: このタスクは Ant のディストリビューションに含まれていない外部ライブラリに依存しています。 詳しくは ライブラリ依存関係をご覧ください。
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.
ftp タスクは、 接続先サーバーから、どのようなファイルシステム記述を返すか判断はせず、デフォルトは Unix の標準となっています。 remotedir は ftp サーバーにおいt正確な記述をしなければなりません。 対象とするサーバーにおいて、通常のUnixの規約がサポートされていない場合には、 代わりに使われるファイル区分子を指定するためにseparator が使えます。
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?
注意: Windows 2000 ftp サーバーで get と delete を正しく動作させるには、 デフォルトのMS-DOS形式ではなく、 Unix 形式のファイル一覧を生成するよう設定しなければなりません。 あるいは、誰かがMS-DOS 形式のファイル一覧をパージングするコードを記述する必要がります。誰かやってくれる人いませんか。
| Attribute | Description | Required |
| server | the address of the remote ftp server. | Yes |
| port | the port number of the remote ftp server. Defaults to port 21. | No |
| userid | the login id to use on the ftp server. | Yes |
| password | the login password to use on the ftp server. | Yes |
| remotedir | the directory to which to upload files on the ftp server. | No |
| action | the ftp action to perform, defaulting to "send". Currently supports "put", "get", "del", "list", "chmod" and "mkdir". | No |
| binary | selects binary-mode ("yes") or text-mode ("no") transfers. Defaults to "yes" | No |
| passive | selects passive-mode ("yes") transfers. Defaults to "no" | No |
| verbose | displays information on each file transferred if set to "yes". Defaults to "no". | No |
| depends | transfers only new or changed files if set to "yes". Defaults to "no". | No |
| newer | a synonym for depends. | No |
| separator | sets the file separator used on the ftp server. Defaults to "/". | No |
| umask | sets the default file permissions for new files, unix only. | No |
| chmod | sets or changes file permissions for new or existing files, unix only. If used with a put action, chmod will be issued for each file. | No |
| listing | the file to write results of the "list" action. Required for the "list" action, ignored otherwise. | No |
| ignoreNoncriticalErrors | flag which permits the task to ignore some non-fatal error codes sent by some servers during directory creation: wu-ftp in particular. Default: false | No |
| skipFailedTransfers | flag which enables unsuccessful file put, delete and get operations to be skipped with a warning and the remainder of the files still transferred. Default: false | No |
| 属性 | 説明 | 必須 |
| server | リモート ftp サーバーのアドレス | Yes |
| port | リモート ftp サーバーのポート番号。 デフォルトは 21 番ポート | No |
| userid | ftp サーバーで使われるログインID | Yes |
| password | ftp サーバーで使われるログインパスワード | Yes |
| remotedir | ftp サーバーへのファイルアップロード先ディレクトリ | No |
| action | 実行する ftp アクション。 デフォルトは "send" 。 現在、"put"、"get"、 "del"、"list"、"chmod" および、 "mkdir"をサポートしています。 | No |
| binary | バイナリモード転送("yes")か、 テキストモード転送か("no")を選択します。 デフォルトは"yes"です。 | No |
| passive | パッシブモード転送("yes") かどうかを選択します。 デフォルトは"no"です。 | No |
| verbose | "yes"に設定された場合、 ファイルが転送される毎に情報を表示します。 デフォルトは"no"です。 | No |
| depends | "yes"に設定された場合、 新規か、あるいは変更されたファイルのみ転送します。 デフォルトは"no"です。 | No |
| newer | dependsと同じです | No |
| separator | ftp サーバーで使われるファイル区分子を設定します。 デフォルトは "/" です。 | No |
| umask | Unix の時のみ、 新規ファイルに対するデフォルトファイルパーミッションを指定します。 | No |
| chmod | Unix の時のみ、新規または既存のファイルに対し、 ファイルパーミッションを設定または変更します。 put アクションで使用した場合、chmod は個々のファイルに対して行われます。 | No |
| listing | "list"アクションの結果の出力先となるファイル。 the "list" アクションには必須で、無い場合は無視されます。 | No |
| ignoreNoncriticalErrors | タスクが、 ディレクトリ生成時にあるサーバにより送られる、 致命的でないエラーコードを無視するのを許可するためのフラグ: 特に wu-ftp など。 デフォルト: false | No |
| skipFailedTransfers | ファイルの送信、削除、取得操作が上手くいかなかった場合に、 警告メッセージを出力しながらスキップし、 残りのファイルの転送を行うのを可能にするフラグ。 デフォルト: false | No |
The 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.apache.org as anonymous and
uploads all files in the htdocs/manual directory
to the default directory for that user.
ftp.apache.orgにanonymousでログインし、
htdocs/manualディレクトリにある全てのファイルを
そのユーザのデフォルトディレクトリにアップロードします。
<ftp server="ftp.apache.org"
remotedir="incoming"
userid="anonymous"
password="me@myorg.com"
depends="yes"
>
<fileset dir="htdocs/manual"/>
</ftp>
Logs in to ftp.apache.org as anonymous and
uploads all new or changed files in the htdocs/manual directory
to the incoming directory relative to the default directory
for anonymous.
ftp.apache.orgにanonymousでログインし、
htdocs/manualディレクトリにある新規の、あるいは更新のあった全てのファイルをそのユーザのデフォルトディレクトリに対する
相対ディレクトリincomingにアップロードします。
<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.apache.org at port 2121 as
coder with password java1 and uploads all new or
changed HTML files in the htdocs/manual directory to the
/pub/incoming directory. The files are transferred in text mode. Passive mode has been switched on to send files from behind a firewall.
ftp.apache.orgの2121番ポートに、
ユーザcoder、パスワードjava1でログインし、
htdocs/manualディレクトリにある新規の、あるいは更新のあった全ての HTML ファイルを /pub/incoming ディレクトリにアップロードします。
ファイルはテキストモードで転送されます。
ファイヤーウォール内からファイルを送るためにパッシブモードにします。
<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 ftp.nt.org as
coder with password java1 and uploads all
HTML files in the htdocs/manual directory to the
c:\uploads directory. Progress messages are displayed as each
file is uploaded.
Windowsベースのftp.nt.orgに、
ユーザcoder、パスワードjava1でログインし、
htdocs/manualディレクトリにある新規の、
あるいは更新のあった全ての HTML ファイルを
c:\uploads ディレクトリにアップロードします。
個々のファイルがアップロードされる際に進捗メッセージが表示されます。
Getting 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サーバーからファイルを取得するのは、 ファイルの送信とほとんど同じ方法で動作します。 唯一の違いは、 ネストするファイルセットが、 FTP サーバー上のファイルのためのベースディレクトリとして、 remotedir 属性を使い、 FTPサイトからのファイル構造はローカルマシンに保持されます。
<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 ftp.apache.org as anonymous and
recursively downloads all .html files from default directory for that user
into the htdocs/manual directory on the local machine.
ftp.apache.orgにログインし、
そのユーザのデフォルトディレクトリから、
再帰的に全ての .html ファイルを
ローカルマシンの
htdocs/manualディレクトリにダウンロードします。
As 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サーバーから削除するファイルを選択するのに、 ネストした fileset 要素が使えます。 繰り返しになりますが、 fileset はリモートディレクトリからの相対パス、ローカルディレクトリからではありません。 実際にファイルセットのdir 属性は完全に無視されます。
<ftp action="del"
server="ftp.apache.org"
userid="anonymous"
password="me@myorg.com" >
<fileset>
<include name="**/*.tmp"/>
</fileset>
</ftp>
Logs in to ftp.apache.org as anonymous and
tries to delete all *.tmp files from the default directory for that user.
If you don't have permission to delete a file, a BuildException is thrown.
anonymousアカウントで
ftp.apache.orgにログインし、
そのユーザのデフォルトディレクトリの全ての *.tmp ファイルを削除しようと試みます。
あるファイルの削除の権限が無い場合、
BuildException がスローされます。
<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 data/ftp.listing of all the files on
the FTP server relative to the default directory of the anonymous
user. The listing is in whatever format the FTP server normally lists files.
これは、
FTP サーバーの
anonymousユーザのデフォルトディレクトリの
ファイル一覧を
data/ftp.listingに出力します。
このリスト形式は FTP サーバーが通常ファイルのリストを生成する形式です。
Note that with the mkdir action, the directory to create is specified using the remotedir attribute.
mkdir アクションにおいて、 生成するディレクトリはremotedir 属性を用いて指定されることに注意してください。
<ftp action="mkdir"
server="ftp.apache.org"
userid="anonymous"
password="me@myorg.com"
remotedir="some/remote/dir" />
This creates the directory some/remote/dir beneath the default root
directory. As with all other actions, the directory separator character must be correct
according to the desires of the FTP server.
これは、
デフォルトルートディレクトリの下に、
some/remote/dirディレクトリを作成します。
他の全てのアクションと同様に、
ディレクトリの区分文字は FTP サーバーが要求するものに従って正しくなければなりません。
Copyright © 2000-2002 Apache Software Foundation. All rights Reserved.