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.
e-mail_daily_log.s
One of the benefits of Robo-FTP is the ability to create set-and-forget processes that notify you of results.
A typical workflow might look something like this:
- Perform a scheduled task (for this example we'll upload a certain file to a server every day).
- Create a daily log with the date in the file name showing what happened.
- E-mail the log file to whoever is responsible for monitoring this task.
To perform the scheduling you can use the built-in Robo-FTP CRON scheduler or simply use the Windows Task Scheduler.
1 ; Create a new log file every time the script runs.
2 ; The log will have the date in it like this:
3 ; daily_upload Oct 30 15.38.43 2007.log
4 ; The file name for the log will be stored in the
5 ; %currentlogfile script variable
6 log "daily_upload" /new
7 ftplogon "myuploadsite"
8 sendfile "file_to_be_uploaded.txt"
9 iferror goto send_error
10 set subject = "SUCCESS"
11 goto done_sending
12 :send_error
13 set subject = "FAILURE"
14 :done_sending
15 FTPLOGOFF
16 ; First, build the e-mail
17 set from_name = "Robo-FTP Script"
18 set from_email = "some@emailaddress.com"
19 set body = "Daily upload results. See attached log for details."
20 set attach = %currentlogfile
21 CREATEMAIL from_name from_email subject body attach
22 ; Next, send the e-mail
23 set to_name = "Bob Smith"
24 set to_email = "bob.smith@mycompany.com"
25 sendmail "my.smtp.server.com" to_name to_email /user=myuserid /pw=mypassword
26 exit

