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:
- Record an FTP script.
- 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
- Connect to your FTP site.
- Click Script > Start Recording.
- Navigate as needed, and transfer or delete files.
- When you are finished, click Script > Stop Recording.
- 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:
- In the FTP Client, click Script > Edit Script.
- Locate the file you created in the previous section and click Open to open the file in Notepad.
- 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
- 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.
- Click File > Save.
- 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.
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.
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.
For a list of products that include Reflection FTP Client, see KB 7021276.