tcpcmd.download
Downloading Files from FTP Serverstcpcmd.download provides a one-line solution for downloading files from FTP servers to your Macintosh.
You can download single files, directories of files, or entire hierarchies of directories and files.
You can access FTP servers with anonymous or private accounts.
The shortest example of tcpcmd.download is:
tcpcmd.download("ftp.scripting.com", "/userland/finderAliases.sit.hqx")This will download the file called "finderAliases.sit.hqx" in the directory "/userland" on the ftp server "ftp.scripting.com". The anonymous (guest access) account is used. The file is downloaded and stored in the root folder of the boot drive. Its name will be "finderAliases.sit.hqx".
Only the first two parameters are required for tcpcmd.download: the ftp server, and the source file.
Note that this yields the same results as
tcpcmd.getURL("ftp://ftp.scripting.com/userland/finderAliases.sit.hqx").You can tell download in what folder to place the file on your hard disk:
tcpcmd.download("ftp.scripting.com", "/userland/finderAliases.sit.hqx", "hard disk:desktop folder:")Here, the file is downloaded and placed on the desktop. The name will still be "finderAliases.sit.hqx".
You can download the file and give it a different file name:
tcpcmd.download("ftp.scripting.com", "/userland/finderAliases.sit.hqx", "hard disk:desktop folder:foo.sit.hqx")The file will be called "foo.sit.hqx" and will be on the desktop.
You can download an entire directory of files (and all the files in all the nested sub-directories):
tcpcmd.download("ftp.scripting.com", "/userland/", "hard disk:desktop folder:")downloads all the files (and all the files in all the sub-directories) in the /userland directory and places them in a folder named "userland" on the desktop.
If you wanted only to download only the files (and not the sub-directories) from the /userland directory:
tcpcmd.download("ftp.scripting.com", "/userland/", "hard disk:desktop folder:", nested:false)Here, we use the optional parameter 'nested' and set its value to false, indicating not to download any sub-directories contained in the /userland directory.
The syntax of tcpcmd.download is:
tcpcmd.download (host, sourcePath [,destPath] [,username] [,password] [,replace] [,nested] [,transferAs] [,timeOut] [,port] [,iso8859] [,bufSize])Where:
hosta
stringcontaining the IP address or domain name of the server to download from"ftp.scripting.com"
sourcePatha
stringcontaining the path to the file or directory you want to download."/userland/finderAliases.sit.hqx"
destPathan optional
stringcontaining the path to the destination file or folder on the Macintosh. If a folder is specified, and it does not exist, it is created. IfdestPathis omitted, the file or folder is placed in the root directory of the boot drive."hard disk:desktop folder:"
usernamean optional
stringcontaining the username of the account you want to log on with. If omitted or blank, "anonymous" is used."myUserName"
passwordan optional
stringcontaining the password for the account you want to log on with."myPassword"If omitted or blank, and the username used was "anonymous" or username was omitted, then the value stored in Frontier's odb at user.mailaddress is used. This is typically set to your email address and it is often what anonymous FTP servers want you to use for password.
replacean optional
booleancontaining eithertrueorfalse. If true, then any file or directory specified in the sourcePath that currently exists on the Macintosh is deleted. If false (the default), then the file or folders will not be deleted. If you set replace to false and the file or folder already exists, an error will occur and the file/folder(s) will not be downloaded.replace:true
nestedan optional
booleancontaining eithertrueorfalse. If true (the default), than all files in all sub-directories in the source path are downloaded.nested:true
transferAsan optional
characteror one-characterstringcontaining one of the following values:If
"A"- ASCII - the file is transferred as an ascii text file.
"I"- bInary - the file is transferred as binary. The contents of the file will be stored in the data fork.
"M"- Macbinary - the file is to be transferred in MacBinary mode, if the host supports it. NOTE: MacBinary transfers are not supported in this version of tcpcmd.
transferAsis omitted ornil(the default), tcpcmd will use "smart" transfer mode selection. If Internet Config is present on the system, tcpcmd will use the filemappings defined in IC to determine the file type, creator and transfer method. If IC is not present, tcpcmd will download files whose names end with ".htm", ".html", ".txt", ".asc", ".hqx", ".uu", and ".uue" as text, saving them with a file type of 'TEXT', and a creator as defined in tcpcmd.properties.textFileCreator. If IC is not present, and the file does not end with a suffix as shown above, it is downloaded with a file type of '????' and a creator of '????'.
timeoutan optionalnumbercontaining the number of seconds download will wait at each step in the sending and receiving process before it gives up and returns to the caller. The default timeout used is defined in tcpcmd.timeouts.ftp.
portan optionalnumberfor the port to use to make the ftp connection. The default is defined in tcpcmd.ports.ftp (port 21). This parameter is necessary if your ftp server uses a port other than the usual ftp port.port:2222
iso8859an optional
booleancontaining eithertrueorfalse. If false (the default), then no translation of the file is performed during download. If true, the file is assumed to be in ISO-8859-1 format and will be converted to the Macintosh character set equivalents during the download.iso8859:true
bufSizean optional
numberspecifying the size of the buffer Frontier should use when downoading a file. The default value is 5120 bytes. Please note that this version of tcpcmd will use up to twice the amount specified inbufSizesince it must use some Frontier string verbs.
Restrictions
tcpcmd.download does not yet support MacBinary protocol.
![]()
This page was last built on 8/1/98; 10:28:41 PM ET by Alan German, asg@erols.com. At the moment, I am using Macintosh OS to work on this website. The "Electric Cactus" graphic is based on original artwork owned by UserLand Software and is used with their permission.