Call now to talk to an automation expert — (512) 345-2211

Script Library

Sample scripts are provided as-is with no warranty of fitness for a particular purpose. These scripts are solely intended to demonstrate techniques for accomplishing common tasks. Additional script logic and error-handling may need to be added to achieve the desired results in your specific environment.


limit_retries.s

Download

NOTE: The technique demonstrated in this script is not needed for file transfer or email commands. Robo-FTP 3.10 and later have built-in features for automatically retrying failed connections in those cases. Use the "Retry Count" and "Retry Delay" settings in the Site Manager in the Configurator to configure this (see the Help file for details).

Error-handling generally falls into to two categories:

  1. Unrecoverable errors, where you typically want to abort the process and notify somebody
  2. Recoverable errors, where you want to simply re-try the failed attempt until it works.

Things get a little trickier when you encounter what should be a recoverable error, but under certain circumstances does not recover. If you are not careful, you can end up with an infinite loop.

One way to avoid this is to use LOOPCOUNT and related commands to limit the number of times you retry something.

The following script attempts to connect to an FTP site 10 times, pausing for one minute between attempts. If it can't connect after 10 tries, it aborts and sends an email notification.


  1  loopcount 10
  2  :connect_loop
  3  ftplogon "mysite"
  4  iferror= $error_success goto connected
  5  pause /for=60
  6  loopto connect_loop
  7  ;; Connection attempts failed 10 times
  8  CREATEMAIL "Script Notifier" "noreply@mycompany.com" "Connection failed" "FTP server appears to be down" ""
  9  sendmail "smtp.mycompany.com" "Sys Admin" "sysadmin@mycompany.com"
 10  EXIT
 11  
 12  :connected
 13  ;; Connection worked -- continue script

Browse complete list of scripts

Need help figuring out where to start?

Our sales staff is available to answer product questions and help you determine if Robo-FTP is a good match for your project.

Call Now: (512) 345-2211