This is a condensed version of a script I wrote that is meant to run Datastage jobs. Each line in the script is headed by appropriate comments to make it easy for you to understand the pieces of code.
You will have to save it with an extension of sh/ksh.Like I said, this is purely a condensed version. The actual code was a bit longer and had many lines of code which were actually relevant to my jobs. You will have to make the necessary additions to the script. Treat this only as a skeletal script. Happy coding.
#!/bin/bash #---------------------------------------------------------------------------------------------------------------------------# # # # Name : Sample.sh # # Created By : Creator # # Description : This shellscript will run the sequencer # # # #---------------------------------------------------------------------------------------------------------------------------# #---------------------------------------------------------------------------------------------------------------------------# # Retrieve number of parameters that have been entered through the command line. In this # # sample I am expecting 2 parameter values # #---------------------------------------------------------------------------------------------------------------------------# NUMPARAM=$# #---------------------------------------------------------------------------------------------------------------------------# # Check if parameters have been entered and set the value to your desired variables # #---------------------------------------------------------------------------------------------------------------------------# if [ "$NUMPARAM" = "2" ]; then PROJECTNAME=$1 PROJECTDIR=$2 else echo "Input paramters not entered" exit 3 fi; #---------------------------------------------------------------------------------------------------------------------------# # Initializing environment parameters to use the Datastage commands # #---------------------------------------------------------------------------------------------------------------------------# cd `cat /.dshome` . ./dsenv > /dev/null 2>&1 #---------------------------------------------------------------------------------------------------------------------------# # Setting parameter sets if you are using it. This piece of code will set the appropriate # # valueset based on the server name.Value set values depend on what you defined for the # # parameter set # #---------------------------------------------------------------------------------------------------------------------------# if [ "$HOST" = "devserver" ]; then vsParameterSet1="vsDEV" fi; if [ "$HOST" = "testserver" ]; then vsParameterSet1=""vsSIT" fi; if [ "$HOST" = "prodserver" ]; then vsParameterSet1="vsPROD" fi; #---------------------------------------------------------------------------------------------------------------------------# # Initialize all the variables you want # #---------------------------------------------------------------------------------------------------------------------------# InterfaceName=”INTERFACE_NAME" INTERFACEDIR=$PROJECTDIR"/"$InterfaceName WORKDIR=$INTERFACEDIR"/datatemp/" SHELLDIR=$INTERFACEDIR"/script/" REJDIR=$INTERFACEDIR"/reject/" #---------------------------------------------------------------------------------------------------------------------------# # Invoking Datastage jobs . The return code of the execution is caught in a variable # #---------------------------------------------------------------------------------------------------------------------------# $DSHOME/bin/dsjob -run -wait -warn 0 -jobstatus -param psParameterSet=$vsParameterSet1 –param Variable1=”sample” $PROJECTNAME $LOGINSEQ > /dev/null 2>&1 RETURNCODE=$? #---------------------------------------------------------------------------------------------------------------------------# # Evaluating the return code # #---------------------------------------------------------------------------------------------------------------------------# if [ $RETURNCODE = 1 -o $RETURNCODE = 2 ] then echo "Job completed successfully" else echo “Job aborting with Return Code :"$RETURNCODE exit 3 fi; #---------------------------------------------------------------------------------------------------------------------------# # ----------------------------------------------End of script ----------------------------------------------------------# #---------------------------------------------------------------------------------------------------------------------------#