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_new_files.s
This script uses FTPDIFF
, and FTPGETDIFF
to check a remote site for files which have changed since the last time you checked.
1 * Log onto the FTP site.
2 FTPLOGON 'site.remote'
3 IFERROR RETURN
4
5 * Change the current directory on the server
6 FTPCD 'outgoing'
7 IFERROR RETURN
8
9 * Check the site for changes.
10 FTPDIFF "*" "ftpsnapshot_test.sql" /append
11 IFERROR RETURN
12
13 :do_getdiff
14 * Check the next difference, and remove the last one from the db
15 FTPGETDIFF "ftpsnapshot_test.sql" /commitlast
16 * An EOF error indicates that all files have been downloaded;
17 IFERROR RETURN $ERROR_SUCCESS
18
19 * if the difference is $DIFF_FILE_NOT_FOUND skip this file
20 * and go back to the top of the loop
21 IFNUM= %ftpdifffileid $DIFF_FILE_NOT_FOUND GOTO do_getdiff
22
23 * the other difference types indicate that the site file is new or has changed,
24 * so let's download it
25 RCVFILE %ftpdifffilename
26 IFERROR RETURN
27 GOTO do_getdiff