In order to use TIBCO ActiveMatrix (R) Adapter for Files (Unix/Win) publication service for pre processing following two fields in the processing tab need to be configured.
1). Pre Processing Script File: Name of the script that needs to be executed before the input file can be processed by the adapter. Click Browse to locate and load the script file.
2) .Pre Processing Arguments: Arguments that need to be passed to the pre-processing script file. These are strings and are optional.
As the adapter starts it checks Recognition method, if it's "By file name" then it runs the pre processing script for specified input file in input directory.
However, if the Recognition method is “Prefix+Extension” it means the file name is not constant. There may be a number of files present at a time in the input directory. The File adapter picks up the file in ascending order and then the Pre-Processing script is run. In this way script is run for each input file with the mentioned prefix.
File adapter executes pre processing script by taking input file name as default argument which is ARG1. If any additional argument is passed in the specified field then that is taken as ARG2..ARG3...
The arguments passed to pre-processing script are as follows:
<script> arg0 arg1 arg2
arg0: <pre-processing script file name>
arg1: <input file>
arg2: <argument specified in "pre processing arguments" field>
After invoking the script the adapter processes the input file normally.
The pre-processing scripts can be used in many scenarios.
The following details two example scenarios.
Scenario 1:
To modify the input file before FA processes it. In this case a preprocessing script can be used to make any changes/modifying the input file and TIBCO ActiveMatrix (R) Adapter for Files (Unix/Win) can then process it.
Scenario 2:
If there are multiple files in the input directory and if we want to skip a particular file then we can use a preprocessing script. The script checks whether a certain file is present in the current directory. If yes then instruct the adapter to skip the input file. In order to skip the file we need to pass the argument %ScriptStatusFile% in the specified field. This creates a temporary status file in the working directory at runtime. Also, we need to append "Skip the input file" message to the status message file.
The script prints all the arguments and adds the line ‘skip the input file’ to the status file (which is argument 2 and substituted automatically at runtime). The script is as follows:
***
echo "Arguments arg0=%0 arg1=%1, arg2=%2"
if exist abc.txt echo "Skip the input file" >>%2
***
The adapter skips the input file if abc.txt is present in the current working directory, otherwise it processes the input file.