user1664398
user1664398

Reputation: 113

Ant script to transfer multiple files using WebSphere MQ File Transfer Edition (MQ FTE)

I have written an ant script to transfer a single file using IBM WebSphere MQ File Transfer Edition.

<target name="filecopy">
   <fte:filecopy src="${src}" dst="${dst}" idproperty="id">
      <fte:filespec srcfilespec="${srcfile}" dstdir="${dstdir}"/>
   </fte:filecopy>
</target>

For two files, the script would look like below:

<target name="filecopy">
   <fte:filecopy src="${src}" dst="${dst}" idproperty="id">
      <fte:filespec srcfilespec="${srcfile1}" dstdir="${dstdir1}"/>
      <fte:filespec srcfilespec="${srcfile2}" dstdir="${dstdir2}"/>
   </fte:filecopy>
</target>

How can I modify the script so that it can support multiple files by accepting a string (e.g. a.txt,b.txt,c.txt) as parameter?

Upvotes: 3

Views: 487

Answers (1)

T.Rob
T.Rob

Reputation: 31832

How can I modify the script so that it can support multiple files?

Since your example already sends multiple files, presumably you are asking how to transfer a variable number of files to be determined at run time. There are a few options.

  1. Use a wildcarded filespec. All matching files will be transferred.
  2. Transfer an entire directory recursively.
  3. Dynamically generate the file transfer XML so as to include a filespec for each individual file.
  4. Use a monitor that starts file transfers based on trigger criteria.

Based on the update, the requirement is to pass a string containing file names. Most likely, you will want to use Option #3 above. Pass the string of file names to something that can parse them, then generate the XML. This can be done with shell scripting, or in Ant using something like , or many other ways. There is nothing in the XSD for MQMFT that allows specification of file names natively as a delimited string.

Upvotes: 3

Related Questions