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.


serve_decrypted_file.s

Download

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

Server Event Scripts are often used to process files that have been uploaded to Robo-FTP Server. For example, you can automatically move/rename/decrypt files that are uploaded. However, Server Event Scripts can also be used to intercept requests and perform more sophisticated tasks.

In this example, we are keeping PGP encrypted files in a user's home directory on the server. When a user attempts to download a file, this Server Event Script will PGP decrypt the file and then serve the decrypted file to the user.

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 serve_decrypted_file.s (use the Download link above)
  • 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 "Begin Download" from the Server Event drop-down list
  • In the Event Script File Name box enter the full path to the serve_decrypted_file.s script file that you saved earlier
  • Click the Apply button

IMPORTANT:

  1. This script is just an example and has minimal error handling. You should add more complete error handling if you are going to use this in production.
  2. This script leaves an unencrypted version of the file in the home directory. You should also create a Server Event Script for the Download Complete event that deletes the file on download. That will be a one-line script:

    DELETE %event_downloadpath

  3. This script may not be appropriate for decrypting large files as the client may experience time-out errors waiting for a very large file to decrypt.

  4. Typically, you would add a .pgp extension when encrypting a file. For example, you would encrypt data.csv to data.csv.pgp. In this case, however, you should give your encrypted file whatever name you want your user to receive when they download the file.

  1  MAKEFILENAME newfile "tmp" %temp% "robo"
  2  IFERROR RETURN
  3  PGPDECRYPT %event_downloadpath newfile
  4  IFERROR RETURN
  5  SET %event_downloadpath = newfile

Browse complete list of scripts