Hello,
I have a command activity stage to get the job statistics as below
DSHOME=`cat /.dshome`;. $DSHOME/dsenv;
SRC_CNT=$($DSHOME/bin/dsjob -linkinfo DS_SANDBOX jb_SRC_TGT_Job_Extract ODBC_WELLHEADER_WELLBORE lnk_ODBC_Stage1 | awk 'NR>1{exit};1{print $5}');
TGT_CNT=$($DSHOME/bin/dsjob -linkinfo DS_SANDBOX jb_SRC_TGT_Job_Extract XFM_Split_I_D_U lnk_XFM_Split_I_D_U | awk 'NR>1{exit};1{print $5}');
REJ_CNT=$($DSHOME/bin/dsjob -linkinfo DS_SANDBOX jb_SRC_TGT_Job_Extract XFM_Split_I_D_U lnk_XFM_Reject | awk 'NR>1{exit};1{print $5}');
REJ_CNT_DUP=$($DSHOME/bin/dsjob -linkinfo DS_SANDBOX jb_SRC_TGT_Job_Extract XFM_Split_I_D_U lnk_XFM_Reject_Dup | awk 'NR>1{exit};1{print $5}');
JOB_STATUS=$($DSHOME/bin/dsjob -jobinfo DS_SANDBOX jb_SRC_TGT_Job_Extract | egrep 'Job Status');
JOB_START_TIME=$($DSHOME/bin/dsjob -report DS_SANDBOX jb_SRC_TGT_Job_Extract | egrep 'Job start time');
JOB_END_TIME=$($DSHOME/bin/dsjob -report DS_SANDBOX jb_SRC_TGT_Job_Extract | egrep 'Job end time');
JOB_ELAPSED_TIME=$($DSHOME/bin/dsjob -report DS_SANDBOX jb_SRC_TGT_Job_Extract | egrep 'Job elapsed time');
echo $SRC_CNT,$TGT_CNT,$REJ_CNT,$REJ_CNT_DUP,$JOB_STATUS,$JOB_START_TIME,$JOB_END_TIME,$JOB_ELAPSED_TIME;
The output of this command is
Reply=0
Output from command ====>
Status code = 0
Status code = 0
Status code = 0
Status code = 0
Status code = 0
63171,49125,12263,1786,Job Status : RUN with WARNINGS (2), Job start time=2019-06-14 07:10:50, Job end time=2019-06-14 07:11:34, Job elapsed time=00:00:44
In the Next User Variable activity stage, I am reading the line 9 which is last line from tje previous stage
SRC_CNT= Field(Ereplace(Field(EC_calculate_counts.$CommandOutput,@FM,9),@FM,''),',',1)
Job_Start_Time=Field(Field(Ereplace(Field(EC_calculate_counts.$CommandOutput,@FM,9),@FM,''),',',6),'=',2)
I want to make below mentioned commands generic to always read the last line instead of Harding coding( hardcoded as 9 in the example below) the line number
SRC_CNT= Field(Ereplace(Field(EC_calculate_counts.$CommandOutput,@FM,9),@FM,''),',',1)
Job_Start_Time=Field(Field(Ereplace(Field(EC_calculate_counts.$CommandOutput,@FM,9),@FM,''),',',6),'=',2)
Please help me on this
Regards
Neeraj
Field Function
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
I wouldn't use Field() function here. Assuming this is the only instance of "Job start" in the whole output, I would use an Index function to work out where it is, and substringing to return the remainder of the last line by providing an arbitrarily large second argument.
You may need a little more processing to remove the final line terminator. For example
Code: Select all
myCommand.$CommandOutput[Index(myCommand.$CommandOutput, "Job start", 1), 999]
Code: Select all
myCommand.$CommandOutput[Index(myCommand.$CommandOutput, "Job start", 1), 999]<1>
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.