Getting started using Ant scripts with MFT
Using Ant scripts with Managed File Transfer allows you to coordinate complex file transfer operations from an interpreted scripting language.
Ant scripts
Ant scripts (or build files) are XML documents defining one or more targets. These targets contain task elements to run. Managed File Transfer provides tasks which you can use to integrate file transfer function into Apache Ant. To learn about Ant scripts, see the Apache Ant project web page: https://ant.apache.org/
Examples of Ant scripts that use Managed File Transfer tasks are provided with your product installation in the directory MQ_INSTALLATION_PATH/mqft/samples/fteant
On protocol bridge agents, Ant scripts are run on the protocol bridge agent system. These Ant scripts do not have direct access to the files on the FTP or SFTP server.
Namespace
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:fte="antlib:com.ibm.wmqfte.ant.taskdefs" default="do_ping">
<target name="do_ping">
<fte:ping cmdqm="qm@localhost@1414@SYSTEM.DEF.SVRCONN" agent="agent1@qm1"
rcproperty="ping.rc" timeout="15"/>
</target>
</project>
The
attribute xmlns:fte="antlib:com.ibm.wmqfte.ant.taskdefs"
tells Ant to look for the
definitions of tasks prefixed by fte
in the library
com.ibm.wmqfte.ant.taskdefs
. You
do not need to use fte
as your namespace prefix;
you can use any value. The namespace prefix fte
is
used in all examples and sample Ant scripts.
Running Ant scripts
To run Ant scripts that contain the file transfer Ant tasks use the fteAnt command. For example:
fteAnt -file ant_script_location/ant_script_name
For
more information, see fteAnt: run Ant tasks in MFT.Return codes
The file transfer Ant tasks return the same return codes as the Managed File Transfer commands. For more information, see Return codes for MFT.