Page 1 of 1

Issue with the unix After job subroutine

Posted: Thu Jun 04, 2009 3:58 am
by monaz
Hi all,

I am using the below unix script is it possible to call DS functions in the script.

Please guide me on this.

#! /usr/bin/ksh
# Load into od_trans_map_output table for HALO Transaction Mapping

#$INCLUDE DSINCLUDE JOBCONTROL.H

echo $1 $2 $3 $4 $5 $6
isql -U$4 -P$5 -S$2 <<-EOI1
use $3
go
truncate table $3..od_trans_map_output_new
go
EOI1
bcp $3..od_trans_map_output in $1 -U$4 -P$5 -S$2 -c -t "," > $6'\'od_trans_map_opt.log

LOG_COUNT=`grep -c 'failed' od_trans_map_opt.log`
Log=`grep -n 'failed' od_trans_map_opt.log`
echo "count:$LOG_COUNT"
if $LOG_COUNT = 1 then
call DSLogFatal("The job aborted because of bcp failed ","ExecSH")
# Abort
end
else
cat od_trans_map_opt.log
fi

Posted: Thu Jun 04, 2009 6:12 am
by chulett
No.

Re: Issue with the unix After job subroutine

Posted: Thu Jun 04, 2009 6:26 am
by vrishabhsagar
monaz wrote:Hi all,

I am using the below unix script is it possible to call DS functions in the script.

Please guide me on this.

#! /usr/bin/ksh
# Load into od_trans_map_output table for HALO Transaction Mapping

#$INCLUDE DSINCLUDE JOBCONTROL.H

echo $1 $2 $3 $4 $5 $6
isql -U$4 -P$5 -S$2 <<-EOI1
use $3
go
truncate table $3..od_trans_map_output_new
go
EOI1
bcp $3..od_trans_map_output in $1 -U$4 -P$5 -S$2 -c -t "," > $6'\'od_trans_map_opt.log

LOG_COUNT=`grep -c 'failed' od_trans_map_opt.log`
Log=`grep -n 'failed' od_trans_map_opt.log`
echo "count:$LOG_COUNT"
if $LOG_COUNT = 1 then
call DSLogFatal("The job aborted because of bcp failed ","ExecSH")
# Abort
end
else
cat od_trans_map_opt.log
fi

I am not very sure of what you are trying to do in the script, But if you are trying to send a message into the logs, then you can probably use dsjob command utility.

Posted: Thu Jun 04, 2009 4:13 pm
by ray.wurlod
Call DSLogFatal is not available in a shell script. It is only available within the DataStage BASIC programming language, which only executes within the DataStage run machine. The same is true of $INCLUDE, though you've commented this out.

Posted: Sat Jun 06, 2009 12:34 am
by monaz
ray.wurlod wrote:Call DSLogFatal is not available in a shell script. It is only available within the DataStage BASIC programming language, which only executes within the DataStage run machine. The same is true of $I ...
Thanks alot Ray,

I am actually capturing the log of bcp and searching if it fails then i need to abort the job.

So i need to write other routine to search and abort the same job. Is it the correct way to follow.

Posted: Sat Jun 06, 2009 6:47 am
by chulett
No, all you need to do is make sure your script exits with a non-zero status if your load has a problem, the job will notice and abort automatically.