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.


unzip_uploaded_file.s

Download

Robo-FTP Server can automatically unzip files as they are uploaded by an FTP, FTPS, SFTP or HTTP(S) client.

This sample script was written for use with Robo-FTP Server v3.2.5. 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 moves the uploaded zip file to a pre-defined directory, unzips the contents, and deletes the zip file. The script automatically quarantines invalid or password protected zip files along with any other files not named with the .zip extension.

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 unzip_uploaded_file.s (use 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 "Upload Complete" from the Server Event drop-down list
  • In the Event Script File Name box enter the full path to the unzip_uploaded_file.s script file that you saved earlier
  • Click the Apply button
  • Select Administration in the navigation bar on the left
  • Write down the name of the account displayed in the Login box. The Login box will be disabled if the service is running but you should still be able to read the account name. Network Service is the name of the default account used by Robo-FTP Server.
  • Create these folders if they do not already exist on your computer: c:\temp, c:\destination and c:\quarantine
  • Right click on each folder and select Properties from the pop-up context menu. Modify the security permissions on each folder to grant Robo-FTP Server's login account permission to read, write, modify, and list files in the folder.

Once all these steps are complete, upload a zip file to Robo-FTP server and then check the c:\destination folder for the unzipped contents. Then upload a non-zip file and verify that Robo-FTP Server moves it to the c:\quarantine folder.

Note: The Robo-FTP client can be used to automatically zip and upload files: Sample script to zip and upload all files


  1  MOVE %event_uploadpath "c:\temp"
  2  SET zip_path = "c:\temp\" + %event_uploadfile
  3  SETRIGHT extension = %event_uploadfile 4
  4  IFNSTRCMPI extension ".zip" GOTO invalid_file
  5  UNZIP zip_path "c:\destination" "*"
  6  IFERROR GOTO invalid_file
  7  DELETE zip_path
  8  RETURN %lasterror
  9  :invalid_file
 10  ;; Not a valid zip file
 11  MOVE zip_path "c:\quarantine"

Browse complete list of scripts