Re: Script endlessly looping
- From: "Chris F.A. Johnson" <cfajohnson@xxxxxxxxx>
- Date: Thu, 5 Jan 2006 15:09:38 -0500
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
.
- References:
- Script endlessly looping
- From: jsciba
- Script endlessly looping
- Prev by Date: Re: Can I see in a telnet session remote tty1
- Next by Date: Re: want shell should I learn?
- Previous by thread: Script endlessly looping
- Index(es):
Relevant Pages
|