Hi,
I have a filewatcher job setup to run and fail when the job completes with a COMPSTAT=4 and the RUNCOUNT=4.
However, I have a problem when the job is rerun again.
if the job is RERUN again, it goes to a NOTOK status due to the fact that the MAXIMUM number of RERUN has been reached (RUNCOUNT=4). Is there a way I can code my job so that on reruning it after the max RERUN counts has been exhausted and the file is available now, the job wont fail, but would pick up the file and complete OK. Any assistance will be appreciated.
I am running on Control-M/EM version 6.1.03 on Solarix OS.
Here is a script of the Script that I am executing for the filewatcher job and what the different exit codes mean
Exit 3 = Missing feed file from one of our databases called CASA
Exit 4 = File is missing
Exit 5 = File is still changing
-------------------------------------------------------------------------------------
#!/bin/sh
# FTP_Side Enrollment Script
# 2003 Thomas Keeley
# Kronova Automation, do it all! Needs a feed file. (SQL output from CASA)
# Check and Basic Setup
if [ "$1" = "" ]; then
echo "DataFeed Error. Call with JOBNAME/DataSource."
exit 3
fi
DataSource="`echo $1 | cut -d'_' -f1`"
KronosDir=/export/kronos/.kronos
LogFile=$KronosDir/job.$DataSource
echo "Starting FTP side Enroll In Script at `date`" | tee -a $LogFile
if [ -f $KronosDir/unix.$DataSource ]; then
cat $KronosDir/unix.$DataSource | tr -d '\r' > $KronosDir/unix.$DataSource.1
mv $KronosDir/unix.$DataSource.1 $KronosDir/unix.$DataSource
. $KronosDir/unix.$DataSource
else
echo "Missing feed file." | tee -a $LogFile
exit 3
fi
# Setup Functions
TestFile() (
echo "Starting file test for $DataSource" | tee -a $LogFile
if [ "`ls -1 | grep -c \^$FilePattern`" != "0" ]; then
t1=/tmp/filetest1.$$
t2=/tmp/filetest2.$$
ls -l $FilePattern* > $t1
sleep 30
ls -l $FilePattern* > $t2
diff $t1 $t2 > /dev/null
RC=$?
rm -f $t1 $t2
if [ "$RC" = "0" ]; then
echo "File exists, continuing..." | tee -a $LogFile
else
echo "File still changing. Aborting." | tee -a $LogFile
exit 5
fi
else
echo "No file found. Aborting." | tee -a $LogFile
exit 4
fi
)
GetBINFile() (
echo "Getting file (Binary Transfer) for $DataSource" | tee -a $LogFile
# FTP all files with $FilePattern in them to the $FTPServer
case $DataSource in
SCHNEIDERELIG)
echo "Starting special one-off process for $DataSource" | tee -a $LogFile
lftp -c "set ftp:ssl-allow no && open -u $FTPUser,$FTPUserPass $FTPServer && cd $RemoteDir && get DEFINITY.pgp || exit 2" >> /tmp/ftpoutlog.$$ 2> /tmp/ftperrorlog.$$
;;
LSGCERIDIANELIG|CERIDIANELIG)
echo "Starting non-deleting process for $DataSource" | tee -a $LogFile
lftp -c "set ftp:ssl-allow no && open -u $FTPUser,$FTPUserPass $FTPServer && cd $RemoteDir && mget $FilePattern* || exit 2" >> /tmp/ftpoutlog.$$ 2> /tmp/ftperrorlog.$$
;;
RIOTINTOELIG)
echo "Starting forced-Active-Mode process for $DataSource" | tee -a $LogFile
lftp -c "set ftp:ssl-allow no && set ftp:passive-mode no && open -u $FTPUser,$FTPUserPass $FTPServer && cd $RemoteDir && mget $FilePattern* || exit 2" >> /tmp/ftpoutlog.$$ 2> /tmp/ftperrorlog.$$
;;
*)
lftp -c "set ftp:ssl-allow no && open -u $FTPUser,$FTPUserPass $FTPServer && cd $RemoteDir && mget -E $FilePattern* || exit 2" >> /tmp/ftpoutlog.$$ 2> /tmp/ftperrorlog.$$
;;
esac
if [ "$?" = "0" ]; then
if [ "`cat /tmp/ftperrorlog.$$`" != "" ]; then
cat /tmp/ftpoutlog.$$ | tee -a $LogFile
echo "File not found on $FTPServer" | tee -a $LogFile
cat /tmp/ftperrorlog.$$ | tee -a $LogFile
rm /tmp/ftp*log.$$
exit 4
else
cat /tmp/ftpoutlog.$$ | tee -a $LogFile
echo "File Retieved" | tee -a $LogFile
cat /tmp/ftperrorlog.$$ | tee -a $LogFile
rm /tmp/ftp*log.$$
fi
else
cat /tmp/ftpoutlog.$$ | tee -a $LogFile
echo "File transfer failed $FTPServer" | tee -a $LogFile
cat /tmp/ftperrorlog.$$ | tee -a $LogFile
rm /tmp/ftp*log.$$
exit 2
fi
)
GetASCIIFile() (
echo "Getting file (ASCII Transfer) for $DataSource" | tee -a $LogFile
# FTP all files with $FilePattern in them to the $FTPServer
lftp -c "set ftp:ssl-allow no && open -u $FTPUser,$FTPUserPass $FTPServer && cd $RemoteDir && mget -aE $FilePattern* || exit 2" >> /tmp/ftpoutlog.$$ 2> /tmp/ftperrorlog.$$
if [ "$?" = "0" ]; then
if [ "`cat /tmp/ftperrorlog.$$`" != "" ]; then
cat /tmp/ftpoutlog.$$ | tee -a $LogFile
echo "File not found on $FTPServer" | tee -a $LogFile
cat /tmp/ftperrorlog.$$ | tee -a $LogFile
rm /tmp/ftp*log.$$
exit 4
else
cat /tmp/ftpoutlog.$$ | tee -a $LogFile
echo "File Retieved" | tee -a $LogFile
cat /tmp/ftperrorlog.$$ | tee -a $LogFile
rm /tmp/ftp*log.$$
fi
else
cat /tmp/ftpoutlog.$$ | tee -a $LogFile
echo "File transfer failed $FTPServer" | tee -a $LogFile
cat /tmp/ftperrorlog.$$ | tee -a $LogFile
rm /tmp/ftp*log.$$
exit 2
fi
)
MoveAndRename() (
echo "Moving $FilePattern files to the scratch area" | tee -a $LogFile
NewFileName="${DataSource}_`date +%Y%m%d%H%M`"
n=0
for file in `ls -1 $FilePattern*`
do
n=`expr $n + 1`
mv $file /export/kronos/${NewFileName}_$n$NewFileExt
echo "$file moved. Renamed to ${NewFileName}_$n$NewFileExt." | tee -a $LogFile
done
)
# Actual Processing
cd $LocalDir || exit $?
if [ "$FileLocation" = "DH_FTP_SERVER" ]; then
TestFile || exit $?
elif [ "$FileLocation" = "REMOTE_FTP_SERVER" ]; then
FTPUserPass="`/export/home/kronos/decryptor/app/scripts/decryptor.sh d $FTPUserPass`"
if [ "$NewFileExt" = ".asc" ]; then
GetASCIIFile || exit $?
else
GetBINFile || exit $?
fi
else
echo "Invalid File Location. Imposible error. See Thomas for details." | tee -a $LogFile
exit 3
fi
MoveAndRename || exit $?
if [ -f $KronosDir/jobout.$DataSource ]; then
echo "FTP Task Standard output:" | tee -a $LogFile
cat $KronosDir/jobout.$DataSource | tee -a $LogFile
rm $KronosDir/jobout.$DataSource
fi
if [ -f $KronosDir/joberr.$DataSource ]; then
echo "FTP Task Error output:" | tee -a $LogFile
cat $KronosDir/joberr.$DataSource | tee -a $LogFile
rm $KronosDir/joberr.$DataSource
fi
echo "Finished FTP Side scripts at `date`." | tee -a $LogFile
exit 0
--------------------------------------------------------------------------------------
Thanks.[/b]
Filewatcher logic dilema
- kijenketile
- Nouveau
- Posts: 4
- Joined: 29 Jan 2007 12:00
- Location: Minneapolis, MN U.S.A
- Contact: