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.
download_recently_modified.s
This script logs onto an FTP server and downloads all files that have been modified in the last 10 minutes.
1 LOOPCOUNT 3
2 :LogonLoop
3 FTPLOGON "my_ftp_site.com" /timeout=60
4 IFERROR= $ERROR_SUCCESS GOTO Operation1
5 ;; Try again for up to 3 attempts
6 LOOPTO LogonLoop
7 STOP
8 :Operation1
9 SET temp = %datetime
10 DATETIMESUB temp 10 /minute
11 SET ten_min_ago = temp
12 FTPGETFILE "*.txt"
13 IFERROR= $ERROR_NO_FILE_FOUND GOTO Disconnect
14 IFDATETIME> %sitefiledatetime ten_min_ago GOTO Operation2
15 GOTO Operation1
16 :Operation2
17 ;; File has been modified within last 10 minutes, so download it
18 RCVFILE %sitefile
19 GOTO Operation1
20 :Disconnect
21 FTPLOGOFF
22 EXIT

