The “Hot Receive” Feature

Top  Previous  Next

 

The GETSITEFILE and RCVFILE commands can be used together to create a service script that automatically downloads files as soon as they are added to a remote site. This type of automatic real-time processing is sometimes known as a "hot receive" process.

 

The following example polls the remote site for new files, downloads them as they appear, and then deletes them from the remote site:

 

:connect

FTPLOGON "ftp.new.com" /user=anonymous /pw=itchy

 

:loop

GETSITEFILE "*" /timeout=0

IFERROR= $ERROR_NO_FILE_FOUND GOTO download_error

RCVFILE %sitefile /delete

IFERROR!= $ERROR_SUCCESS GOTO download_error

GOTO loop

 

:download_error

FTPLOGOFF

GOTO connect

 

Warning: This example script will download the same file repeatedly if you don't have sufficient credentials to delete files from the remote server.

 

The FTPRENAME command may be used to move the remote file out of watched folder on the remote folder instead of simply deleting it.

 

If you do not wish to remove files from the remote site after they are downloaded you'll need a method of distinguishing new files from existing files and also for recognizing when existing files are modified.  In these situations you should use FTPDIFF and FTPGETDIFF instead of GETSITEFILE to identify and track which remote files need to be downloaded.  The FTPDIFF command also supports the the /incldirs option if you need to descend into a subdirectory tree.

 

Related: The "Hot Send" Feature, Using the %sitefile and %sitedir Variables, Programming Service Scripts