Automating FTP Transfers with Reflection FTP Client Scripts

  • 7021274
  • 30-Mar-2000
  • 02-Mar-2018

Environment

Reflection FTP Client version 14.x or higher

Situation

This technical note explains how to automate FTP transfers with the Reflection FTP Client. The following instructions explain how to record and edit a Reflection FTP script, and run the script using Reflection command line parameters, such as from Windows Scheduled Tasks.

Resolution

Note: This technical note describes scripting capability in Reflection FTP Client, which does not provide error handling. Alternatively, if you want to control Reflection FTP Client from another application (.NET, VBA, etc.) or implement error handling, use the COM/OLE Automation API instead. For more information and API programming examples, see KB 7021275.

Using the FTP Client, you can automate file transfers following these steps:
  1. Record an FTP script.
  2. Create a Windows shortcut, batch file, or shell command that calls the FTP Client and runs your FTP script.

Generating a Reflection FTP Script File

Once you have successfully configured the Reflection FTP Client to automatically connect to an FTP server, you can automate file transfers using the Script Recorder

  1. Connect to your FTP site.
  2. Click Script > Start Recording.
  3. Navigate as needed, and transfer or delete files.
  4. When you are finished, click Script > Stop Recording.
  5. Save the script file with .rfs file name extension.

For more information on which actions are captured by the Script Recorder, see https://docs.attachmate.com/reflection/ftp/15.6/guide/en/t_7474.htm.

Editing the FTP Script File

Depending on how your FTP Client is configured, certain actions may require user intervention, which could stall the automatic processing of your FTP script. To avoid this problem, edit your script as described below:

  1. In the FTP Client, click Script > Edit Script.
  2. Locate the file you created in the previous section and click Open to open the file in Notepad.
  3. Insert the following commands at the top of your FTP script.
SET TRANSFER-DISPOSITION OVERWRITE
SET RESUME-PARTIAL-TRANSFERS NEVER
SET CONFIRM-DELETE NO
SET SMART-TYPE-DEFAULT BINARY
  1. At the end of your script add a line with the Quit command so that Reflection FTP exits when your script is finished. Quit only causes FTP Client to close when the script is initiated from a command line.
QUIT
  1. Click File > Save.
  2. Exit Notepad.

For more information on FTP script commands and settings, see https://docs.attachmate.com/reflection/ftp/15.6/guide/en/t_7513.htm.

Testing the FTP Script

After you have saved the script, connect to your FTP site and click Script > Run Script to test your script.

Initiating the Script from the Command Line

You can run your script from the command line in a BAT file, Windows Shortcut, scheduler program, or shell command.

<path>RFTPC.EXE "<FTPSiteName>" /RFS "<path>\Script.rfs" /L "<path>\Log.log"

For more information about executable startup switch parameters, see https://docs.attachmate.com/reflection/ftp/15.6/guide/en/t_7450.htm.

Example

The following command would start Reflection FTP Client from its default location, connect to the FTP Site named "MySFTPSite," run the script FTPScript.rfs, and create a log file C:\Temp\FTPLog.log on Windows 7 64-bit:

"C:\Program Files (x86)\Attachmate\Reflection\rftpc.exe" "MySFTPSite" /RFS "C:\Users\UserId\Documents\Attachmate\Reflection\Logs\FTPscript.rfs" /L "C:\Temp\FTPLog.log"

Test your command line in the Windows Start Run dialog box until the Reflection FTP Client opens, runs your script, and closes.

Scheduling Events

You can use Windows Task Scheduler or an equivalent to run the command at a specific time and day.

For tasks to be run by the Task Scheduler, Windows requires that the account running the task be logged on to Windows or have "Log on as a batch job" permissions. For more information, see KB 7021931.

Additional Information

For a list of products that include Reflection FTP Client, see KB 7021276.

Legacy KB ID

This document was originally published as Attachmate Technical Note 1308.