Sunday

Sample Unix shell Scripts

#ksh: JobNum.sh

#Author: Prasad Degela

#Date: 03/13/2006

#Reviewed by By:

#Date:

#Project: Appeals & Grivances Tracking

####################################################################################

#This script will call .env file to get common variables.

# SET PARAMETERS - Part 1

# These parameters are provided for all interfaces.

# $1 = environment (DEV)

####################################################################################

#set -x

####################################################################################

. /etldata/aagt/common/scripts/aagt.env

inboxdir=$PROJECTDIR/qnxt/inbox

srcfiledir=$PROJECTDIR/qnxt/estage

errorfiledir=$PROJECTDIR/qnxt/error

tempfiledir=$PROJECTDIR/nice/tstage

tempfiledirqnxt=$PROJECTDIR/qnxt/tstage

ERROR_EXIT_STATUS=99

SUCCESS_EXIT_STATUS=0

echo "Control Moved to the Inbox Directory = "$inboxdir

cd $inboxdir

fileconv=`echo "PDP*.txt"`

echo "fileconv = "$fileconv

files=`ls -tr $fileconv`

if [[ $? -ne 0 ]]

then

echo "No Source File in the InBox "$inboxdir

exit $SUCCESS_EXIT_STATUS

fi

echo "List Of Files in the Inbox Directory "$inboxdir

echo "{ $files }"

for pfilename in $files

do

cd $inboxdir

cp $pfilename $srcfiledir

gzip $pfilename

cp $pfilename.gz $ARCHFILEDIR

rm -f $pfilename.gz

rm -f TRAIL*.txt

echo "Source File Name Is "$pfilename

pDSjobname="sjAG01"

pINVOKE_ID=$pfilename

pJobStatusFile=`echo $pfilename".stat"`

pJobLogFile=`echo $pfilename".log"`

####################################################################################

# RESET AND RUN job sequencer #

####################################################################################

$DSBINDIR/dsjob -jobinfo $DSPROJECT $pDSjobname.$pINVOKE_ID > $LOGFILEDIR/$pJobStatusFile

JOBSTATUS=`grep "Job Status" $LOGFILEDIR/$pJobStatusFile | cut -f2 -d '('|cut -f1 -d ')'`

echo "$pDSjobname Job status code is "$JOBSTATUS

if [[ $JOBSTATUS = 3 ]]

then

echo "Job Status = "$JOBSTATUS

$DSBINDIR/dsjob -run -mode RESET -wait -jobstatus $DSPROJECT $pDSjobname.$pINVOKE_ID

echo "************************* Reset the Job Sequencer *******************"

fi

echo AGDB: $AGDB

echo AGDBUserID: $AGDBUserID

echo ORADB: $ORADB

echo ORADBUSRID: $ORADBUSRID

echo NICEDB: $NICEDB

echo NICEDBUserID: $NICEDBUserID

echo SrcFile: $pfilename

echo SrcFileDir: $SRCFILEDIR

echo TempFileDirectory: $TEMPFILEDIR

echo TempFileDirectoryqnxt:$TEMPFILEDIRQNXT

echo ErrorFileDirectory: $ERRORFILEDIR

echo ScriptFileDirectory: $SCRIPTFILEDIR

echo "calling $Jobname Sequence"

$DSBINDIR/dsjob -run \

-param AGDB=$AGDB \

-param AGDBUserID=$AGDBUserID \

-param AGDBPswd=$AGDBPswd \

-param ORADB=$ORADB \

-param ORADBUSRID=$ORADBUSRID \

-param ORADBPswd=$ORADBPswd \

-param NICEDB=$NICEDB \

-param NICEDBUserID=$NICEDBUserID \

-param NICEDBPswd=$NICEDBPswd \

-param SrcFile=$pfilename \

-param SrcFileDir=$SRCFILEDIR \

-param TempFileDirectory=$TEMPFILEDIR \

-param TempFileDirectoryqnxt=$TEMPFILEDIRQNXT \

-param ErrorFileDirectory=$ERRORFILEDIR \

-param ScriptFileDirectory=$SCRIPTFILEDIR \

-wait -jobstatus $DSPROJECT $pDSjobname.$pINVOKE_ID

$DSBINDIR/dsjob -jobinfo $DSPROJECT $pDSjobname.$pINVOKE_ID > $LOGFILEDIR/$pJobStatusFile

$DSBINDIR/dsjob -logsum $DSPROJECT $pDSjobname.$INVOKE_ID > $LOGFILEDIR/$pJobLogFile

JOBSTATUS=`grep "Job Status" $LOGFILEDIR/$pJobStatusFile | cut -f2 -d '('|cut -f1 -d ')'`

echo "$pDSjobname Job status code is "$JOBSTATUS

if [[ $JOBSTATUS = 1 ]]

then

echo "Job Status = "$JOBSTATUS

echo "Removing File from $srcfiledir on successful processing of file $pfilename"

cd $srcfiledir

rm -f $pfilename

else

exit $ERROR_EXIT_STATUS

fi

done

echo 99 END OF THE PROG

exit $SUCCESS_EXIT_STATUS

#

#####################################################################################################

No comments :

Post a Comment

Recent Comments