Shell Script Execution |
Scroll |
Shell scripts can also be used to invoke the Replicator Engine either directly or using through a request to the local Controller Daemon.
Syntax
sqdrpl <name>.rpl > <name>.rpt 2>&1
The following syntax is used for invoking the Replicator Engine on Linux using the SQDMON utility and a local sqdaemon
sqdmon <agent_name>
Keyword and Parameter Descriptions
<name>.rpl The name of the Replicator Engine script file used as input to the Replicator. The recommended file extension for the script file .rpl
<name>.rpt Recommended name for the report file produced on demand or at normal termination of the Replicator Engine.
<agent_name> - Agent name specified in sqdagents.cfg file. Typically the <replicator>.rpl file name without the extension or the name specified as the subscribing Engine in the source Capture/Publisher configuration (CAB) file.
Example 1
Execute a Db2/z to Kafka Replicator at the command line after first archiving the previous Report (.rpt) and Log (sqdrpl-<pid>.log files renamed with Time Stamps in directories previously created for that purpose.
#!/bin/bash
for f in sqd*_*.log
do
mv -n "$f" ./logs/"$(date -r "$f" +"%Y%m%d_%H%M%S")_$f"
done
for f in *.rpt
do
mv -n "$f" ./rpts/"$(date -r "$f" +"%Y%m%d_%H%M%S")_$f"
done
sqdrpl ./ENGINE/DB2RKAFKA.rpl > DB2RKAFKA.rpt 2>&1
Example 2
Execute a Db2/z to Kafka Replicator managed by a local sqdaemon Controller Daemon using the SQDMON utility after first archiving the previous Report (.rpt) and Log (sqdrpl-<pid>.log files renamed with Time Stamps in directories previously created for that purpose.
for f in sqd*_*.log
do
mv -n "$f" ./logs/"$(date -r "$f" +"%Y%m%d_%H%M%S")_$f"
done
for f in *.rpt
do
mv -n "$f" ./rpts/"$(date -r "$f" +"%Y%m%d_%H%M%S")_$f"
done
sqdmon start DB2RKAFKA
Example 3
When the sqdaemon Controller Daemon is first started, as is typically done following maintenance of the Linux Host system, execute a Db2/z to Kafka Replicator and an IMS to Oracle Apply Engine managed by a local sqdaemon Controller Daemon using the SQDMON utility after first archiving the previous Report (.rpt) and Log (sqdrpl-<pid>.log files renamed with Time Stamps in directories previously created for that purpose.
Define an ALLENGINES agent in the sqdagents.cfg file with auto_start=yes:
[ALLENGINES]
TYPE=program
program=./sqdatash.sh
args=ALLENGINES
working_directory=/home/nTEST/dae_FileDates
stderr_file=/home/nTEST/ALLENGINES.rpt
stdout_file=/home/nTEST/ALLENGINES.rpt
auto_start=yes
In the same sqdagents.cfg file define the two Engine Agents with auto_start=no
[DB2TOKAF]
type=engine
program=sqdrpl
args=./ENGINE/DB2RKAFKA.rpl
working_directory=/home/nTEST
message=/home/nTEST/dae_FileDates
stderr_file=/home/nTEST/DB2RKAFKA.rpt
stdout_file=/home/nTEST/DB2RKAFKA.rpt
auto_start=no
[IMSTOORA]
TYPE=ENGINE
program=sqdata
args=./ENGINE/IMSTOORA.prc
working_directory=/home/nTEST
stderr_file=/home/nTEST/IMSTOORA.rpt
stdout_file=/home/nTEST/IMSTOORA.rpt
auto_start=no
Define a shell script sqdatash.sh referenced by the ALLENGINES agent.
#!/bin/bash
for f in sqd*_*.log
do
mv -n "$f" ./logs/"$(date -r "$f" +"%Y%m%d_%H%M%S")_$f"
done
for f in *.rpt
do
mv -n "$f" ./rpts/"$(date -r "$f" +"%Y%m%d_%H%M%S")_$f"
done
sqdmon start DB2RKAFKA
sqdmon start IMSTOORA