ftp automation

ScriptFTP

The professional tool to automate FTP, SFTP, FTPS and schedule FTP batch jobs

The forum is now read only. Please, go to the the main ScriptFTP website if you need help.
Need help writing a script? Have any question about ScriptFTP?
Hi,

I have a script that checks for the presence of a flag file on a server using the following code:
FTP Script
  1. :GAD_FLG
  2.  
  3.       $result=GETFILE("GAD_".$date.".flg")
  4.  
  5.       IF($result!="OK")
  6.          PRINT("ERR - GAD flag not present")
  7.          SLEEP(300)
  8.          GOTO :GAD_FLG
  9.       ELSE
  10.          PRINT("INF - GAD flag present")
  11.          GOTO :CustomerAgentEmail
  12.       END IF
If the flag exists the rest of the script runs and downloads a bunch of files. My problem is that I only really want this script to run for a maximum of an hour as if the files are not available within this window they cannot be processed without disrupting users.

Is it possible to set a maximum retry limit on a particular section of the script (i.e. in this case the GOTO: GAD_FLG loop)? I guess I could rename a file incrementally, check for its existence and then exit the loop when it reaches the magic number but it's not a particularly elegant way to do it.

Cheers

John
FTP Script
  1. $aCount = 1
  2. # 60 sec*5 min
  3. $aPause = 60*5
  4. # 60 min*60sec/aPause
  5. $aMaxCount = 60*60/$aPause
  6.  
  7. :GAD_FLG
  8.  
  9. $result = GETFILE("GAD_".$date.".flg")
  10.  
  11. IF($result != "OK")
  12.   PRINT("ERR - GAD flag not present")
  13.   IF($aCount > $aMaxCount)
  14.     GOTO :End
  15.   END IF
  16.   SLEEP($aPause)
  17.   $aCount = $aCount+1
  18.   GOTO :GAD_FLG
  19.   PRINT("INF - GAD flag present")
  20.   GOTO :CustomerAgentEmail
  21.  
  22. # bla-bla-bla
  23.  
  24. :CustomerAgentEmail
  25. # bla-bla-bla
  26.  
  27. :End
Thanks for answering wandrey