Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ant

ibm-mq

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?

like image 604
user1664398 Avatar asked Dec 06 '25 06:12

user1664398


1 Answers

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 ant-contrib, or many other ways. There is nothing in the XSD for MQMFT that allows specification of file names natively as a delimited string.

like image 154
T.Rob Avatar answered Dec 08 '25 23:12

T.Rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!