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.
hot_receive.s
This example script is designed to be used with Robo-FTP's Service Installer program to create a Windows Service that contstantly watches a remote server and download files as they appear in a single remote folder.
To avoid downloading files that are still being written on the server, Robo-FTP checks the file size at 5 second intervals and only downloads files after the size stops changing.
Before running this example script, please change:
- The download destination folder on line 1.
- The server logon information on line 6.
- The remote source folder on line 7. Remove line 7 if you need to download from the root folder on the remote site.
1 WORKINGDIR "c:\download\destination\folder"
2 LOG "hot_receive_script.log" /maxsize=1000 /append
3 TRACELOG "hot_receive_trace.log" /maxsize=1000 /append
4 TMPNAME "" ".part"
5 :start
6 FTPLOGON "10.10.0.22" /servertype=SFTP /user=UserID /pw=Secret
7 FTPCD "/remote/source/folder"
8 :get_file_stats
9 GETSITEFILE "*" /timeout=0
10 IFERROR GOTO done
11 SET size1 = %sitefilesize
12 PAUSE /for=5
13 GETSITEFILE %sitefile
14 SET size2 = %sitefilesize
15 IFNUM= size1 size2 GOTO download_now
16 PAUSE /for=5
17 GOTO get_file_stats
18 :download_now
19 RCVFILE %sitefile /delete
20 GOTO get_file_stats
21 :done
22 FTPLOGOFF
23 PAUSE /for=60
24 GOTO start