The problem is with the search string (since the search string contains spaces).
But with a single search string in grep (like "OK" or "FAILED" ) it's working fine.
So i have decided to go with search string as "FAILED".
. /opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/dsenv
sfile=$(date "+status.%m.%d.%H.%M.txt")
touch $sfile
for job_name in `/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servername -user unam -password pwd -ljobs PRJDEV`
do
if `/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -server servname-user unam -password pwd -jobinfo $job_name PRJDEV | grep "Job Status *: RUN FAILED" `; then
echo $job_name >> /path/$sfile
fi
done
is there any way to find the job_name in the output of -ljobs is a job sequence or normal job?
In general -ljobs list out both sequences and jobs.
How we can identify those?
I have changed the requirement little bit.
Previously i have developed the script only for specific project.
Now i have decided to extend it to server level.
i have decided to drop the option of searching last run time for yesterday.
The modified script is:
I have modified the script as generic forserver level.
I have named the script as who_got_failedv1.0.ksh and posting here.
Let me know your comments and feedbacks:
#who_got_failedv1.0.ksh
#-------------------------------------------------------------------------------------------------
#Useful to find out the jobs in aborted state in a particular project
#If we fail to address any of the job failure, then this script will alert us with the job name
#This is much useful in the environment in which more abends are occuring everyday
#Version 1.0:
#-----------------------------------------------------------------------------------------------------
#this version is extended to server level rather than project level.
# This script will looks for all the projects available in a server and finds out the aborted one.
#------------------------------------------------------------------------------------------------
. /opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/dsenv
sfile=$(date "+status.%h.%d.%Y.%H.%M")
touch $sfile
to_list="abc@xyz.com"
/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -lprojects >> prj
for prj_name in `/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -lprojects`
do
for job_name in `/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -ljobs $prj_name`
do
/opt/app/dstage/DataStage752/Ascential/DataStage/DSEngine/bin/dsjob -jobinfo $prj_name $job_name 2>&1 | grep FAILED >/dev/null 2>&1
if [ $? -eq 0 ]
then
echo $prj_name - $job_name >> /path/$sfile
fi
done
done
if [ -s $sfile ]
then
j=`cat prj|wc -l|sed -e 's/^[ \t]*//'`
i=1
while [ $i -le $j ]
do
i=`expr $i + 1`
pr=`sed -n "${i}p" prj|sed -e 's/^[ \t]*//'`
k=`cat $sfile| grep $pr |wc -l|sed -e 's/^[ \t]*//'`
echo "there are $k abends in $pr" >> body.txt
done
sed 's/$'"/`echo \\\r`/" $sfile > $sfile.txt
(cat body.txt;uuencode $sfile.txt $sfile.txt) | mailx -s "Alert:there are some Abends" $to_list
rm $sfile
rm prj
rm body.txt
fi
Last edited by pandeesh on Wed Aug 10, 2011 11:34 am, edited 2 times in total.