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.


email_on_upload.s

Download

This sample script was written for use with Robo-FTP Server v3.4. The steps may vary slightly for newer or older versions. This sample script is NOT for use with the Robo-FTP client.

Robo-FTP Server provides a powerful event-driven automation interface which enables you to launch Robo-FTP scripts in response to events such as a user logging on, uploading a file, etc. This interface is called Server Event Scripts.

Several built-in variables are automatically populated whenever a Server Event Script is triggered. These variables contain information relevant to the event. For example, when a user uploads a file, variables are populated with information like the filename, the path to the file, etc. This knowledge base article describes the events and built-in variables available: KB#271.

The sample script below is designed to be triggered by the Upload Complete event. When executed by Robo-FTP Server, it sends an email notice that includes the full path to the file, the name of the user that uploaded the file and the file size. If an error occurs during the upload then the error number will be included in the message.

To configure Robo-FTP Server to launch the event script at the appropriate time, follow these steps:

  • Download this sample script and save it as email_on_upload.s (use the Download link above)
  • Configure a new email server configuration:
    • From the Windows Start Menu's Robo-FTP Server folder, launch the Script Settings program
    • Select Outbound Email (SMTP) in the navigation bar on the left
    • Click the "Add" button to configure a new email server if one does not already exist
    • Make note of the "Site Name" you have assigned to this server for later use
    • Press the "Test" button to confirm you are able to send email with the inputted settings, and "OK" to commit
  • Edit the script file and save the following changes:
    • Change the email_sitename value to the "Site Name" of the email server configured above
    • Change the from and to values to real addresses
  • Launch Robo-FTP Server Console
  • Select Automation in the navigation bar on the left
  • Select "Enable for all" under Server Event Scripts on the right
  • Select "Upload Complete" from the Server Event drop-down list
  • In the Event Script File Name box enter the full path to the email_on_upload.s script file that you saved earlier
  • Click the Apply button

Note: If you don't know your SMTP server's address and authentication requirements you can make the changes described in KB#321 to use a GMail account for testing purposes.


  1  SET body = "The Upload Complete event was triggered on Robo-FTP Server.  " + %crlf + %crlf
  2  SET body = body + "File: " + %event_uploadpath + "  " + %crlf + %crlf
  3  SET body = body + "Size: " + %event_uploadfilesize + "  " + %crlf + %crlf
  4  SET body = body + "User: " + %event_logonname + "  " + %crlf + %crlf
  5  SET body = body + "Please do not reply to this message."
  6  SET err_msg = ""
  7  IFNUM= %event_uploadresult $ERROR_SUCCESS GOTO send_msg_now
  8  SET err_msg = "An error was reported. [" + %event_uploadresult + "]  " + %crlf + %crlf
  9  
 10  :send_msg_now
 11  SET body = err_msg + body 
 12  SET from = "Robo-FTP Server "  
 13  SET subj = "File upload notice"
 14  SET email_sitename = "mycompany_email_config"
 15  SET to = "Steve Johnson "
 16  
 17  EMAIL body /server=email_sitename /subject=subj /from=from /to=to 
 18  EXIT

Browse complete list of scripts