Script endlessly looping
- From: jsciba@xxxxxxxxxxxx
- Date: 5 Jan 2006 11:43:36 -0800
The following script has a loop that executes ftp to look for a trigger
file on a remote server. If the file is found, the loop breaks and
another ftp is done to retrieve a zipped data file. It deletes the
trigger file and renames the data file on the remote server. Then the
script copies and unzips the data file. Finally, it removes the zipped
file and the trigger file from the local server. This works 99% of the
time flawlessly. But the last several days, the script performs all its
tasks and then starts executing the loop again. It has to be killed
manually. The script is executed by Informatica as a pre-session
script.
Can anyone spot a problem?
-------------------------------------------------------------------------------------------------------------------------
#!/bin/ksh
ftp_rc=0;export ftp_rc
rcnt=0;export rcnt
etlData='/vc/extract/MrkFncl';export etlData
etlArch='/vc/extract/MrkFncl/archive';export etlArch
etlLogs='/vc/extract/MrkFncl/logs';export etlLogs
shdir='/vc/extract/MrkFncl/scripts';export shdir
cd $etlData
#
*************************************************************************
# * Function to get files from ftp server
*
#
*************************************************************************
function GetData
{
ftp -v -n 999.999.99.9 <<EOF > $etlLogs/UKGetLog.log << not real
IP
user xxxxxxxx xxxxxxxx << not real
login
type binary
del mrsukext.bak
del mrsuktrg.rec
get mrsukext.rec
ren mrsukext.rec mrsukext.bak
quit
EOF
ftp_rc=$?
}
#
*************************************************************************
# * Check for trigger file on ftp server
*
#
*************************************************************************
function CheckTrigger
{
ftp -v -n 999.999.99.9 <<EOF > $etlLogs/UKGetLog.log << not real
IP
user xxxxxxxx xxxxxxxx << not real
login
type binary
get mrsuktrg.rec
quit
EOF
ftp_rc=$?
}
#
*************************************************************************
# * Function to check log file for successful login
*
#
*************************************************************************
function CheckLogFile
{
export FailCode=`grep -c "logged in" $etlLogs/UKGetLog.log`
if [[ $FailCode = 0 ]]
then
exit 3
fi
}
#
*************************************************************************
# * Function to check for the trigger file
*
# * If file doesn't exists, process sleeps for 600 seconds and trys
again*
#
*************************************************************************
until false
do
CheckTrigger
if [ -f $etlData/mrsuktrg.rec ]
then
break
fi
sleep 600
done
#
*************************************************************************
# * Function to get the data file
*
#
*************************************************************************
GetData
CheckLogFile
#
*************************************************************************
# * Function to copy the data file to backup
*
# * Function to unzip the data file
*
#
*************************************************************************
cp mrsukext.rec $etlArch/mrsukext.rec_`date '+%m%d%y%H%M'`
unzip -p mrsukext.rec > $etlData/mrsukext.dat
rm mrsukext.rec
rm mrsuktrg.rec
exit $retcode
.
- Follow-Ups:
- Re: Script endlessly looping
- From: Chris F.A. Johnson
- Re: Script endlessly looping
- Prev by Date: Re: Useful use of cat
- Next by Date: Re: how to edit only one paragraph
- Previous by thread: Script to strip lines from files
- Next by thread: Re: Script endlessly looping
- Index(es):
Relevant Pages
|