Hi there.
I am having an issue with a return value from a shell script.
In the script I just have the command exit 1 to simulate an error, but for some reason when I execute it from the sequence it does not return an error it shows:
cis_seq..JobControl (@Coordinator): Summary of sequence run
11:35:34: Sequence started (checkpointing on)
11:35:34: find_ciramst (COMMAND find) started
11:35:34: find_ciramst finished, reply=0
11:35:34: Check_Partition (COMMAND E:\scripts\check_partition.ksh) started
11:35:34: Check_Partition finished, reply=0
11:35:34: Sequence finished OK
Any ideas?
Thanks
Execute command with sequnce
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
What kind of trigger(s) do you have on the Execute Command activity? Do you have any other form of error handling, such as "automatically handle activities that fail" or an Exception Handler?
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.
Yes I tried a terminator activity on an output trigger of failure with the same results. I talked to someone at IBM support about this and we tried a couple of things that did not work. Interestingly enough, when we tried a bat file instead of ksh file, it worked fine. I think they are going to chalk it up to being an MKS toolkit issue. I would write my stuff in bat files but we are eventually going to a linux platform I did not want to waste time writing bat files. The workaround for me is just to script everything in a Korn shell and not count on the execute command activity.
Thanks
Thanks
We are handling the same concept of using Execute activty to run the shell script- I was able to trap the error code of the Shell script and also SQL error:
This is the code: the Return of status(SQL_STATUS=$?) at the end would help. If you dont have SQL it can also take any status coming out of the shell.
NOTE: all variables in { } are Datastage Environmental variables
This is the code: the Return of status(SQL_STATUS=$?) at the end would help. If you dont have SQL it can also take any status coming out of the shell.
NOTE: all variables in { } are Datastage Environmental variables
Code: Select all
!/bin/ksh
############################################################################
# Program : WL_InitLoadRegistry.ksh
#
# Summary : This shell script will Truncate the Staging Table, Drop and
# Recreate the Tmp Table.
#
# Input : Tables: STG_REGISTRY
#
# Output : Tables: TMP_REGISTRY
#
#
# Developer : AvishekMukherjee
#
# Date : Apr-18-2006
#
# Modification History
# Version Modified by Date Modified Modification
# --------------------------------------------------------------------------
#
############################################################################
FILE_NAME=`basename $0 .ksh`
SPOOL_FILE=${LOGFILES}/TableLoads/$FILE_NAME.spool
LOG_FILE=${LOGFILES}/TableLoads/$FILE_NAME.log
DT_START=`date`
echo "-----------------------------------------" >> $LOG_FILE
echo "Execution Started at :"$DT_START>>$LOG_FILE
echo "Connecting to Oracle...">>$LOG_FILE
tab=`$ORACLE_HOME/bin/sqlplus -s /nolog <<EOF >>$LOG_FILE
CONNECT ${DB_USER}/${DB_PASSWORD}@${DB_NAME}
set lines 250
set trims off
set wrap off
set head off
set pages 0
spool $SPOOL_FILE
WHENEVER SQLERROR EXIT SQL.SQLCODE;
TRUNCATE TABLE ${DB_STG_SCHEMA}.STG_REGISTRY;
DROP TABLE ${DB_STG_SCHEMA}.TMP_REGISTRY;
CREATE TABLE ${DB_STG_SCHEMA}.TMP_REGISTRY
AS SELECT *
FROM ${DB_STG_SCHEMA}.REGISTRY
WHERE 1 = 2;
spool off;
exit
EOF`
SQL_STATUS=$?
if [ ${SQL_STATUS} -ne 0 ]
then
echo "Error in the SQL...." >>${LOG_FILE}
else
echo "Successfully Completed...." >>${LOG_FILE}
fi
DT_END=`date`
echo "Execution Ended at :"$DT_END>>$LOG_FILE
echo "--------------------------------------------">>$LOG_FILE
exit ${SQL_STATUS}
Avishek Mukherjee
Data Integration Architect
Chicago, IL, USA.
Data Integration Architect
Chicago, IL, USA.
I am working in Unix environment.seanc217 wrote:Hi thanks for the code.
Are you running in a Unix environment? or windows?
The issue I am having is in a windows environment. Even if I exit with an exit code it is not returning a non-zero code when using an execute command activity.
Avishek Mukherjee
Data Integration Architect
Chicago, IL, USA.
Data Integration Architect
Chicago, IL, USA.