Remote Directory Polling Script Example
Please note that this script requires Beyond
FTP Version 2.4.05 or above.
The following script polls a remote 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.
Note that the directory being polled is the same one to which the Local Polling script sends files. By running both scripts together, you can cause a file to make a round trip from the polling directory watched by Local Polling to the Incoming directory used by this script.
Download
this script example. |
# We first create the remote directory, if it is not already there.
:From: C:\BFTPDEMO\nmwin.BAT
:To: {APTServe}C:\Remote Demo\%LN\nmwin.bat
# Next, use the file presence
conditional to wait for files to appear
# in the remote directory. We use the wild card for Local Server
# Name to make this unique, so multiple demos may be executed
# simultaneously. 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
{APTServe}C:\Remote Demo\%LN\*.Txt,1
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\RemotePolling.DCF
:Stop:
:End_If:
# The presence check is satisifed. Copy the files in from
APTServe.
# Note that Archive is set. This means the copied files will be moved
# to {APTServe}C:\Remote Demo\%LN\Archive. This prevents
# copying the same file twice.
:Instructions:None
:Archive:Source
:Speed:OFF
:From: {APTServe}C:\Remote Demo\%LN\*.Txt
:To: C:\BFTPDemo\Incoming\*.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: XferOfRemoteDemo
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: {APTServe}C:\Remote Demo\%LN\ARCHIVE\*.*
:Queue_Distribution: C:\BFTPDemo\RemotePolling.DCF
:End_If:
|