Re: Script endlessly looping



On 2006-01-05, jsciba@xxxxxxxxxxxx wrote:
> 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

You should check that cd succeeds.

[snip]
> # *************************************************************************
> # * 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=$?
> }
[snip]
> # *************************************************************************
> # * Function to check for the trigger file *

Function? I don't see a function, just a loop.

> # * If file doesn't exists, process sleeps for 600 seconds and trys again*
> # *************************************************************************
>
> until false

That is the same as the more common:

while true

> do
> CheckTrigger
>
> if [ -f $etlData/mrsuktrg.rec ]

Since you have cd-ed to $etlData, why bother putting it there?

if [ -f mrsuktrg.rec ]

> then
> break
> fi
>
> sleep 600
> done

If this loop never breaks, then the file is never retrieved, or
it's not in the place you are looking for it.

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
.



Relevant Pages

  • Re: Report in FM 6 or 7
    ... achieve this report format will have to be done via scripting. ... but they will simplify the script and Sort Order. ... End Loop ... The normal 'Dancer' field is used so that if there are more than one ...
    (comp.databases.filemaker)
  • Re: recreate database script not work
    ... I got a script which is supposed to regenerate database systax. ... REM gen_dbse_9.sql ... end loop; ...
    (comp.databases.oracle.server)
  • Re: Loop Problem (At Least I think)
    ... If there are no images matching the product ... "" Then" statement (the one below the loop, outside of it), is this just ... >> script to finish. ... > 2) Read the database table and acess the dictionary object for the ...
    (microsoft.public.scripting.vbscript)
  • Re: How to set up a global variable in a sub-routine?
    ... the 'global variables' are more like constants ... ... single script, I need a way to tell it only once where the file is and ... So, if you construct a loop with a loop variable, you ... >programmers avoid global variables completely. ...
    (perl.beginners)
  • RE: (Urgent) Create many txt files from tables with DTS Package
    ... when i run this script the error show: ... > How to loop through a global variable Rowset ... >> D.90.70.0002 Husain Djojonegoro BOARD OF COMMISSIONER ... >> D.50.04.0071 Putu Supertama Checker BI ...
    (microsoft.public.sqlserver.dts)