Hi All,
Can any one suggest me how to run/execute a job/sequencer from UNIX prompt.
This is what I am trying to do..
I have a unix script that checks for a file every 15min, once found I want to script to execute my master sequencer.
Also if there is any post on this topic please suggest the link.
Thanks & Regards
How to RUN a DataStage Job/Sequencer from UNIX
Moderators: chulett, rschirm, roy
Code: Select all
dsjob -run projectname jobname
Last edited by kris007 on Thu Oct 05, 2006 3:08 pm, edited 1 time in total.
Kris
Where's the "Any" key?-Homer Simpson
Where's the "Any" key?-Homer Simpson
Yeah the script which kcblad gave was very useful...I also had developed a less complex script which worked for me with the file watcher concept if you do not have any parameters to pass
Generally you need to search for any file has landed in your Infile folder.... check if the file FTP is complete...append the file name with timestamp....then log it somewhere in a table or directly kick of the job...now the daemon script should know which job to kick of for which file..so that can also be used with a table..we use this kind of concept a lot in ETL projects..post of you need conceptual help.
this is the simple code which might help..
Code: Select all
#!/bin/ksh
############################################################################
# Program : DSExecuteJob.ksh
#
# Input : Datastage Job Name, Datastage Project Name
#
#
# Output Parameters: 0 - For Success
# Error Description - For failure
#
# Developer : CTS
#
# Date : August-03-2006
#
# Modification History
# Version Modified by Date Modified Modification
# --------------------------------------------------------------------------
############################################################################
############################################################################
#
# Store Input Parameters in Shell Variables
#
############################################################################
FILE_NAME=`basename $0 .ksh`
DSJOBNAME=$1
DSPROJNAME=$2
BinFileDirectory=`cat /.dshome`/bin
DSHOME="/opt/ds/Ascential/DataStage/DSEngine"
DSJOBPATH="/opt/ds/Ascential/DataStage"
DSLOG="DS_"$DSJOBNAME
DSLOG_FILE=/WSI/ETL/Conversion/LogFiles/Misc/$DSLOG.log
rm $DSLOG_FILE
############################################################################
#
# Displaying the parameters in log file
#
############################################################################
echo "Log File Name: "$DSLOG_FILE >> $DSLOG_FILE
echo "Datastage Job to Run:"$DSJOBNAME >> $DSLOG_FILE
echo "Datastage Project: "$DSPROJNAME >> $DSLOG_FILE
echo "Datastage Bin: "$BinFileDirectory >> $DSLOG_FILE
cd $DSHOME
. ./dsenv
cd $DSJOBPATH
############################################################################
#
# DataStage EXECUTION of the job sequencer
#
############################################################################
DT_START=`date`
echo "-----------------------------------------">>$DSLOG_FILE
echo "Execution Started at for Datastage Job Sequencer:" $DSJOBNAME " on date:"$DT_START>>$DSLOG_FILE
################################################################################
# Check old job status here
################################################################################
JOB_STATUS=`${BinFileDirectory}/dsjob -jobinfo $DSPROJNAME $DSJOBNAME | head -1 | cut -d"(" -f2 | cut -d")" -f1`
echo "Before run JOB_STATUS=$JOB_STATUS"
case $JOB_STATUS in
################################################################################
# 0 "Running"
################################################################################
0)
echo "Job $DSJOBNAME already running.Job run Failed." >> $DSLOG_FILE;
exit 1
;;
################################################################################
# Runnable Job Status (do something)
# 1 "Finished"
# 2 "Finished with Warning (see log)"
# 9 "Has been reset"
# 11 "Validated OK"
# 12 "Validated (see log)"
# 21 "Has been reset"
# 99 "Compiled"
################################################################################
1|2|7|9|11|12|21|99)
:
;;
################################################################################
# NOT Runnable Job Status (reset job)
# 0 "Running"
# 3 "Aborted"
# 8 "Failed validation"
# 13 "Failed validation"
# 96 "Aborted"
# 97 "Stopped"
# 98 "Not Compiled"
################################################################################
*)
echo "${BinFileDirectory}/dsjob -run -mode RESET -wait $DSPROJNAME $DSJOBNAME"
${BinFileDirectory}/dsjob -run -mode RESET -wait $DSPROJNAME $DSJOBNAME
RETURN_VALUE=$?
if [ $RETURN_VALUE -ne 0 ]
then
echo "Unable to reset job $DSJOBNAME already running..Job run Failed." >> $DSLOG_FILE
exit $RETURN_VALUE
fi
esac
################################################################################
# Execute job here
################################################################################
echo "${BinFileDirectory}/dsjob -run -jobstatus -wait $DSPROJNAME $DSJOBNAME"
${BinFileDirectory}/dsjob -run -jobstatus -wait $DSPROJNAME $DSJOBNAME
RETURN_VALUE=$?
################################################################################
# NOT Runnable Job Status (reset job)
# 0 "Running"
# 3 "Aborted"
# 8 "Failed validation"
# 13 "Failed validation"
# 96 "Aborted"
# 97 "Stopped"
# 98 "Not Compiled"
################################################################################
case $RETURN_VALUE in
1|2)
echo "Job $DSJOBNAME completed successfully "
;;
0)
echo "Error: $DSJOBNAME job failed. error code was -ALREADY RUNNING- Code $RETURN_VALUE" >> $DSLOG_FILE
;;
3|96)
echo "Error: $DSJOBNAME job failed. error code was -ABORT- Code $RETURN_VALUE" >> $DSLOG_FILE
;;
8|13)
echo "Error: $DSJOBNAME job failed. error code was -Failed Validation- Code $RETURN_VALUE" >> $DSLOG_FILE
;;
97)
echo "Error: $DSJOBNAME job failed. error code was -Stopped- Code $RETURN_VALUE" >> $DSLOG_FILE
;;
9)
echo "Error: $DSJOBNAME job failed. error code was -Not Compiled- Code $RETURN_VALUE" >> $DSLOG_FILE
;;
*)
echo "Error: $DSJOBNAME job failed. error code was $RETURN_VALUE" >> $DSLOG_FILE
;;
esac
EXIT_STATUS=$?
if [ ${EXIT_STATUS} -ne 0 ]
then
echo "Error in the Shell for calling the Datastage job sequencer:" $DSJOBNAME >>$DSLOG_FILE
else
echo "Successfully executed the Shell for calling the Datastage job sequencer:" $DSJOBNAME >>$DSLOG_FILE
fi
DT_END=`date`
echo "Execution Ended on $DT_END with Shell Status as :"$EXIT_STATUS>>$DSLOG_FILE
echo "--------------------------------------------">>$DSLOG_FILE
exit ${EXIT_STATUS}
Avishek Mukherjee
Data Integration Architect
Chicago, IL, USA.
Data Integration Architect
Chicago, IL, USA.