This is a nested element of the SSH task; each element represents a
single SFTP session and can be used to transfer files, make
directories, delete files or change file modes. Each element has
only one action however multiple elements may be added to each
<ssh> task. For transfer operations the element supports nested FileSet and
FileList elements
Parameters for <sftp>
The <sftp> element opens an SFTP session on the SSH connection
and performs a single action.
Attribute | Values | Required |
action |
Determines what operation will be executed within this SFTP session. The valid actions are "get", "put", "delete", "mkdir", "rmdir" and "chmod" |
yes |
remotedir |
Specifies the directory on the remote host to use as the root
of the operation. Defaults to the users home directory. |
No |
depends |
If set to true source files will only be transfered if they
are newer that the destination file. Defaults to false |
No |
newer |
A synonym for depends |
No |
mode |
Sets the file mode for use with
the "chmod" action; this must be an octal number for example file mode
"644" |
Yes if action is "chmod" |
skipfailedtransfers |
Do not stop operation of the
task if file transfers fails. Defaults to false |
No |
umask |
The Unix style umask to use when
creating new files on the remote server. Defaults to 022 |
No |
verbose |
Output detailed information.
Defaults to false |
No |
Uploading files to the remote
computer
<sftp action="put" remotedir="ant_rules" verbose="true"> <fileset dir="../release/java/dist"> <include name="*.jar"/> </fileset> </sftp>
Downloading files to the local
computer
<sftp action="get"> <fileset dir="."> <include name="*.gz"/> </fileset> </sftp> <sftp action="get"> <filelist dir="." files="archive.tar.gz"/> </sftp>
Deleting files
<sftp action="delete" remotedir="ant_rules" <fileset> <include name="*.jar"/> </fileset> </sftp>
<sftp umask="077" action="mkdir" remotedir="ant_rules_umask"/>
<sftp action="rmdir" remotedir="ant_rules_umask"/>
<sftp mode="666" action="chmod" remotedir="ant_rules" verbose="true"> <fileset> <include name="*.jar"/> </fileset> </sftp>