Part 2: Customer Question Regarding Automation with MQ Visual Edit

So, continuing with the customer, after they successfully tested MQ Batch Toolkit on Windows with a scheduled Windows batch script, they had a new question:

how can we be sure that the file.txt are send in the proper order ( chronological) from the 1 to last ( by time)

So, here are the batch/scripts files from this blog posting updated to handle getting a list of files by sorted date.

Windows Batch File:

@echo off
setlocal

cd /D C:\Capitalware\MQBT\

for /F %%f in ( 'dir C:\app\some\place\*.txt  /A-D-H /O:D /B' ) do (
  mqbt insert -p MQWT1 -q TEST.Q1 -S -f %%f
  move /Y %%f C:\app\some\place\backup\
)

endlocal

Notes:
– The “/A-D-H” parameter says do not include directories or hidden files.
– The “/O:D” parameter says sort by date.
– The “/B” parameter says only output the file name.

Linux/macOS/Raspberry Pi Script:

#!/bin/sh

PATH="/home/mqm/Capitalware/MQBT:$PATH"
export PATH

cd /home/mqm/Capitalware/MQBT/

ls -tr /app/some/place/*.txt | while read entry
do
  if [ -f "$entry" ];then
     mqbt insert -p MQWT1 -q TEST.Q1 -S -f "$entry"
     mv -f "$entry" /app/some/place/backup/
  fi
done

Notes:
– The “-tr” parameter of the ls command says sort files by time oldest first.

Hope that helps.

Regards,
Roger Lacroix
Capitalware Inc.

This entry was posted in Capitalware, IBM MQ, IBM MQ Appliance, Linux, macOS (Mac OS X), MQ Batch Toolkit, MQ Visual Edit, Programming, Raspberry Pi, Windows.

Comments are closed.