
Automatic FTP Utility
This utility will allow you to transfer many files from many servers at the click of a button based on command files that gives a list of servers and files to transfer.
In the zip file listed below, there are two files - ftp.cfm and test.ftp
ftp.cfm is the FTP utility and test.ftp is an example command file.
Contents of test.ftp:
; FTP Transfer File
;
; These command files must have a .FTP file extension
;
; Commands:
; open
; Syntax: open [server:port] [UserID] [Password]
;
; close
; Syntax: close
;
; dl (download)
; Syntax: dl [protocol (B=Binary, A=ASCII)] [full directory and filename on remote server] [full directory path ONLY local server]
;
; ul (upload)
; Syntax: ul [method (B=Binary, A=ASCII)] [full directory and filename on local server] [full directory path ONLY on remote server]
;
; email (Email results)
; Syntax: email [email address]
;
; The Local and Remote file names for Uploading and Downloading can be dynamic using CF functions.
; Example:
; dl B /apps/www/logs/archive/apache.logs.#DateFormat(Now(),"mm.dd.yy")#.tar C:/Internet/Webalizer/iwof2.tar
;
; The remote file name will be evaluated out to /apps/www/logs/archive/apache.logs.12.22.04.tar
;
; WARNING: File names are CaSe SeNsAtIvE!!! Even if it's Windows, this tool expects the case to match. While transfers will still work
; otherwise, the transfer information will only display if it matches.
;
; Note: ";" identifies a comment line, don't use it for your actual command list.
;
; ======================================================================================================================================
;
; Example of downloading a static text file with ASCII protocol
open ftp.mozilla.org:21 anonymous anonymous
dl A /pub/mozilla.org/README C:\ReadMe.txt
close
When you first execute ftp.cfm, it scans the directory it resides in for all files with a .ftp extension and presents them to you in order to select one. Until you create your own FTP command files, ftp.cfm would display the following upon execution:
FTP Transfer Tool
Please select a FTP process to execute:
test
When you click on the link for the test ftp command file, the FTP utility will validate the command file and will display any errors. If no errors are found, it will display a list of commands that it will execute and present you with a button to actually execute the task.
FTP Transfer Tool
Validating rules...
Validation successful.
Commands:
Open FTP connection to ftp.mozilla.org on port 21
Download file /pub/mozilla.org/README to C:\ReadMe.txt using ASCII protocol
Close FTP connection
When you click the Execute Commands button, you'll be presented with the FTP transfer progress as it occurs, not when the entire process is complete. If the transfer takes more than a second, the average throughput of the transfer will be displayed.
FTP Transfer Tool
10:52:45: Opening connection to ftp.mozilla.org... done.
10:52:46: Changing directory to /pub/mozilla.org... done.
10:52:50: Downloading README to C:\ReadMe.txt using ASCII protocol. . . done. 1.1 KB transfered in 0.8 seconds
10:52:59: Closing connection... done.
10:53:00: Program execution complete.
Return to FTP menu
If you want to automatically execute the process if the validation was sucessful, you need to specify the FTP command file on the URL along with AutoRun=Y. So if you want to automatically execute the test.ftp command file, you would execute ftp.cfm?ftp=test&AutoRun=Y&RequestTimeout=9999
Download file: ftp.zip
Return to the Cold Fusion Tips-N-Tricks topic list