Local Directory Polling Script Example
Please note that this script requires
Beyond FTP Version 2.4.05 or above.
The following script polls a local directory for files to transfer. It does this by waiting at a file presence
conditional for a specified time period. If any file activity occurs in the directory, the
conditional is released, the resulting files are copied, and the script terminates.
Download
this script example. |
# We first create the polling directory, if it is not already there.
:From: C:\BFTPDEMO\nmwin.BAT
:To: C:\BFTPDEMO\Polling\INPUT.BAT
# Next, use the file presence
conditional to wait on files to appear
# in the Polling directory. Wait 5 minutes for something to happen.
# This time could be much longer if you choose, since the script will
# simply be restarted anyway.
:IF:
Not
C:\BFTPDemo\Polling\*.Txt,5
Present
# We did not find any files. Simply queue the distribution to start
# again and exit. This statement could actually occur first in the
# script, since we always want the script to run. However, it makes
# canceling the script more difficult. We place it here (and below
# when the script works) to make it easier to cancel things once they
# get started.
:Queue_Distribution: C:\BFTPDemo\LocalPolling.DCF
:Stop: # on a failure we stop here
:End_If:
# The presence check is satisifed. Copy the files out to the
# destination server. The file is placed on APTServe, where the
# Remote Polling script will pick it up if it is running. Note that
# Archive is set. This means that as the source files are copied,
# they will be moved to c:\BFTPDemo\Polling\Archive.
# This prevents copying the same file twice.
:Instructions:None
:Archive:Source
:Speed:OFF
:From: C:\BFTPDemo\Polling\*.Txt
:To: {APTServe}C:\Remote Demo\%LN\*.Txt
# Next, we check to see whether all the transfers have completed
# successfully. If they have, we delete the archive files.
# Otherwise, we simply restart the distribution and exit.
:IF:
PollingXfer
CompletedOK
# We delete the archive files when the transfers have completed.
# We could also move them to a different directory, or simply leave
# them here. If a transfer fails, there will still be files in the polling
# directory. The next operation of the script will detect this, and
# immediately attempt another transfer.
:Delete_Files: C:\BFTPDEMO\Polling\ARCHIVE\*.*
:End_If:
# so we execute the Queue command no matter what
# happens to the script
:Queue_Distribution: C:\BFTPDemo\LocalPolling.DCF
|