Anda di halaman 1dari 3

Script 1: Set Environment Script: This script is used to identify the server and set the value for

the variables l ike env, domain, project etc.. #!/bin/ksh ############################################################################# # Script Name : SETENV # # Description : Set environment variables # # # Parameters : None # # Change Log: # # Changed By Date Description # ----------------------------------------------------# Abhinav Yerramreddy 26/Nov/10 Initial # ################################################################################ ##### Server=`uname -n | tr '[:lower:]' '[:upper:]'` if [ $Server -eq "AppServ1" ] then env=Development domain=AppServ1.na.com elif [ $Server -eq "AppServ2" ] then env=Quality domain=AppServ2.na.com elif [ $Server -eq "AppServ3" ] then env=Production domain=AppServ3.na.com fi echo $domain Uname=newton Pwd=apples DSProject=TestProject Mail_List="abhinav@newtonapples.com" Script 2: Run Job Script This script will run the jobs that are passed to it and will send out a notifica tion email to users after the jobs finish/abort. Make sure that SETENV.sh script is available before running this script #!/bin/ksh ############################################################################# # Script Name : Run_Job_Script # # Process Name: Run all sequencers # # Description : Executes UNIX & DataStage Components # # # Parameters : Job Name #

# Change Log: # # Changed By Date Description # ----------------------------------------------------# Abhinav Yerramreddy 26/Nov/10 Initial # ################################################################################ ##### #set -x #Create the process Log file Runid=`date +%Y%m%d` StartTS=`date +%Y%m%d%H%M%S` #. ./.profile . /home/abhinav/Scripts/SETENV.sh # Check input parameters JobName=$1 FileTS=$StartTS WorkDir=/home/abhinav/workdirectory # Mention the Data element name for the log file LogDir=$WorkDir/Logs LogFileName="$JobName"_"$FileTS".log #Assigning File Name Format FileName="Project1_${FileTS}.dat" #DataStage Path/Project/Job DSPath=="/is/IBM/InformationServer/Server/DSEngine/bin" #Assigning Configuration file based on Process Acronym ConfigFile="/is/IBM/InformationServer/Server/Configurations/default.apt" #echo "Config File : " $ConfigFile |tee -a $LOG #Execute dsenv . /is/IBM/InformationServer/Server/DSEngine/dsenv if [ $# -eq 0 ] then cd $LogDir LogFileName=JobNotFound"$LogFileName" echo "Usage : $0" >> $LogFileName ( uuencode "$LogFileName" "$LogFileName" )| mailx -s "Job Name Not Passed To Scr ipt" -r dsadmin@newtonapples.com "$Mail_List" exit 1 fi #echo "Datastage job "$JobName " is started at: " $(date) # process steps eval 'dsjob -domain $domain -user $Uname -password $Pwd -server $Server -run -pa ram "String=$env" -param "Path=$env" -param "Email_Notification=ETL_Team" -wait -jobstatus $DSProject $JobName' es=$? if [ $es -eq 0 ] || [ $es -eq 1 ] then echo "Datastage job :" $JobName : "Executed Successfully" exit 0

fi if [ $es -eq 2 ] then echo "DataStae job :" $JobName : "Executed successfully with Warnings" exit 0 elif [ $es -eq 3 ] then echo "DataStage Job Aborted" exit 4 else cd $LogDir echo "Failed to execute the job :" $JobName: "\n Please check if the job is available and in compiled state" >> $LogFileName ( uuencode "$LogFileName" "$LogFileName" )| mailx -s "The job $JobName falied to start " -r dsadmin@newtonapples.com "$Mail_List" exit 4 fi #exit 0

Usage: How to run the script? 1. Put the SETENV.sh script in an particular path on your server 2. Change the path of the SETENV.sh in Run_Job_Script.sh to the path specified i n step 1 3. Run the Run_Job_Script by passing the name of the job as parameter sh Run_Job_Script.sh Job_1

Anda mungkin juga menyukai