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_send.s
A common requirement is to upload a local file as soon as it is dropped into a specified local directory. This type of job is sometimes called "hot send."
Robo-FTP provides numerous commands that are designed to make it easy to monitor a directory for the existence of a certain file or files.
This example uses GETNEXTFILE. See the Help file to determine which command is most appropriate for your situation. Other commands with similar functionality include GETSITEFILE, GETFILE, and FTPGETFILE.
This example monitors a local directory (which could also be a network share) for the existence of any file. It will wait indefinitely until a file appears. Once a file is dropped in the directory, the script logs in to a remote FTP server, uploads the file, and moves the local file to an archive directory.
Instead of (or in addition to) uploading the file you could perform other processing on the file (like adding it to a zip archive, PGP encrypting, etc.).
In most cases, it makes sense to run a script like this as a service which runs in the background and starts automatically when the server reboots. See the Help file for instructions on launching a Robo-FTP script as a service.
1 LOG "robo-ftp_script.log"
2 TRACELOG "robo-ftp_trace.log"
3
4 WORKINGDIR "C:\upload_dir"
5 ARCHIVEDIR "C:\archive"
6 FTPLOGON "MyRemoteSite"
7 :loop
8 GETNEXTFILE "*" /timeout=0
9 ;; When a file appears, the file name is stored in the
10 ;; built-in variable %nextfile
11 SENDFILE %nextfile /archive
12 GOTO loop