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.
email_custom_error_messages.s
A common requirement is to send email notifications when certain errors are encountered.
Robo-FTP enables you to check for success / failure of any command (sufficient for most purposes) with the IFERROR command. You can also use variants of the IFERROR command such as IFERROR= to check for specific error messages.
The Help file contains full documentation for IFERROR and related commands, including many examples.
This simple example attempts to set the local working directory. If it is unable to do so, it generates a custom error message and sends an email notification.
1 set localdir = "C:\some\directory"
2 SET ErrorMsg = "Could not change working directory to " & localdir
3 WORKINGDIR localdir
4 IFERROR= $error_success goto operation2
5 ;; There was an error, so send custom email message
6 set mail_to = "admin@mycompany.com"
7 set mail_from = "noreply@mycompany.com"
8 set mailsubj = "Robo-FTP encountered an error"
9 SET mailbody = ErrorMsg & %crlf & %lasterrormsg
10 CREATEMAIL "" mail_from mailsubj mailbody ""
11 SENDMAIL "smtp.mycompany.com" "" mail_to /user=mailuser /pw=mailpw
12 goto done
13 :operation2
14 ;; Do more processing here
15 :done
16 exit

