Script endlessly looping



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

.



Relevant Pages

  • Re: FTP in ASP.NET C#
    ... It has native .NET classes that will allow you to use the FTP protocol. ... >I would like to have my application FTP a file to a server after a user ... > ' This script assumes the file to be FTP'ed is in the same directory as ... > ' If there are multiple files to put, we need to use the command ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Why would it appear to my scripts that a server theyre connecting to has gone away (using Net::F
    ... ftp server. ... LWP::DebugFile is sufficient to prevent the script from freezing or ... and uses ftp to transfer files from a clients web server to their ... LWP is asked to retrieve a few MB from the same server (in the LWP ...
    (comp.lang.perl.misc)
  • Re: how to encrypt password stored in ftp script
    ... I need that script to run everyday automatically on machine ... people form modifying script to access the FTP server for different ... uploading from the system, is to find the most secure way of doing it, ...
    (comp.lang.perl.misc)
  • Re: FTP Upload
    ... I have had an FTP script transferring files between my SBS2K3 server ... No problems until a few weeks ago when suddenly the command line FTP ... I then removed the SBS firewall completely and lo ...
    (microsoft.public.windows.server.sbs)
  • Re: Removing triggers
    ... To build a script, ... create trigger test$insert ... declare @noop int ... Pro SQL Server 2000 Database Design ...
    (microsoft.public.sqlserver.programming)