RCVFILE Receive one or more files |
Top Previous Next |
When connecting to a HTTP/HTTPS site, only the following options are valid with the RCVFILE command: /allowerrors, /as, /delete, /lower, /nounderscores, /timeout=xx, /upper
The RCVFILE command requests that specified file(s) be sent by the FTP site to Robo-FTP. Upon completion of the command, the %downloadcount script variable contains the total number of files downloaded and the %downloadsize script variable contains the size in bytes of the most recent file downloaded. If the /allowerrors option is specified, the count of any file I/O errors is recorded in the %downloaderrors variable.
The following command requests a file named “file name” be sent from the current FTP site directory to be saved as a file with the same name in Robo-FTP’s working folder:
RCVFILE "file name"
When relative path names are specified, as in the following command, a file is retrieved from the current FTP site directory and is saved in the local folder specified by the relative path. In the following example, a file named "file name" is downloaded from the FTP site and saved with the same name in a local folder named “localdir” relative to Robo-FTP’s current working folder.
RCVFILE "localdir\file name"
If you wish to obtain FTP site files from a different directory, use the FTPCD command to navigate accordingly on the FTP site before issuing the RCVFILE command. For example, the following command requests a file named “file name” be sent from an FTP site directory named “serverdir” to be saved in Robo-FTP working folder:
FTPCD "serverdir" RCVFILE "filename"
The /as option allows you to request a certain file be sent by an FTP site that is saved as a different file name on the local system. Consider the following example.
RCVFILE "serverfile" /as "localfile" /type=BIN
The /iflarger, /ifnsamesz, /ifnewer, and /ifnotexist options may be used to control the overwriting of local files. These options are all mutually exclusive. When using the /ifnewer option, the determination of the newest file is based on a comparison of the time and date each file was last written to. The file write time comparison is based only on the hour and minute.
Important If a given FTP site is hosted on a Unix system and the server file was last written to six (6) or more months prior to the current date, the comparison is based on the stored month, day, and year - but the server file time is assumed to be 12:00 AM (since the actual time is not available to Robo-FTP for comparison purposes).
If you are not using the TIMEZONE script command, you may specify the /tz option with the /ifnewer option to account for differences in timezones between Robo-FTP and the FTP site. This is important for accurate file date and time stamp comparisons. For example, if you are using Robo-FTP in the Central U.S. timezone and the FTP site is located in the Eastern U.S. timezone there is a one-hour difference between the file system times of Robo-FTP’s PC and the FTP site. To allow for this in the RCVFILE command with the /ifnewer option, the command would look like the following which indicates that the FTP site is one hour ahead:
RCVFILE "serverfile" /ifnewer /tz=+1
Further, if the FTP site is located in the Pacific U.S. timezone there is a two-hour difference the other way between the file system times of Robo-FTP’s PC and the FTP site. To allow for this, the command would look like the following which indicates that the FTP site is two hours behind:
RCVFILE "serverfile" /ifnewer /tz=-2
The /integrity option enables file integrity checking to be used during the download. When using file integrity checking, the checksum is calculated for both the server file and the local file, using the algorithm specified, then these are compared to verify the integrity of the file. If these do not match then an error is returned. (NOTE: Not all servers support this option.) The possible algorithm are:
Consider the following example where all files are download from the server with file integrity checking using the SHA256 algorithm.
RCVFILE "*.*" /integrity=SHA256 IFERROR= $ERROR_INTEGRITY_CHECKING_FAILED GOTO integrity_error
The /resume and /resumeany options implement the FTP restart (or resume) feature. When this option is specified, Robo-FTP assumes that an attempt is being made to resume a broken transfer on the specified file. Robo-FTP attempts to coordinate with the FTP site regarding the size and last modified date of the file to determine if the transfer can be resumed from the point of interruption. If so, only the unsent portion of the file is retrieved and appended to the incomplete portion received previously. If Robo-FTP determines that it is not safe to resume a transfer, the RCVFILE command fails if /resume is specified, or the entire file is retransmitted if /resumeany is specified.
The /lower and /upper options cause Robo-FTP to convert directory and/or file name(s) specified by [ file name ] and [ new file ] to lower or upper case, respectively, before attempting to locate them on the FTP site for retrieval.
The /maxrate option causes Robo-FTP to limit the bandwidth used when downloading a file. The value, specified in Kbps, is an upper limit and the actual throughput will be something less than but close to the value specifed (assuming the connection is capable of sustaining a download at roughly the rate specified). This option overrides (if the rate specified is non-zero) any global transfer rate for the given FTP site that may may been specifed when the site was defined using the Robo-FTP configurator.
The /maxrate option is not available with Robo-FTP’s standard FTP mode. To enable this functionality, select AltFTP mode for non-secure FTP transfers, or one of the SFTP or FTPS modes modes for secure transfers. For example, the limit a download to 100Kbps, you’d specify the following command.
RCVFILE "serverfile" /maxrate=100
The /type option overrides the default set for a given FTP site. EBCDIC file transfer mode is not permitted unless IBM Host Features mode is enabled.
To receive files from an FTP site where the file name is unknown, or to receive all the files on the FTP site, use wildcards or use the GETSITEFILE command in conjunction with RCVFILE.
Use of the /nostatus option may improve file transfer throughput especially if you are receiving many small files and/or there are a large number of files in the FTP site directory. Use of this option suppresses the sending of an FTP LIST command for each file prior to retrieving it which can significantly reduce network traffic. Locally the only affect of using this option is the suppression of the file progress bar and cancel button which appear in the receive file status dialog box.
The /delete option automatically deletes the file on the FTP site after it has been successfully retrieved.
The /serverdate option instructs Robo-FTP to update the last modified date and time of the local file to match the date and time reported by the FTP site for the corresponding file that was just downloaded. The time of the file will be accurate to the minute (the seconds field is not updated). If the FTP site is hosted on a Unix system, the time saved for the local file is accurate only for files updated on the FTP site within the current year since the file time of older files is not available to Robo-FTP. The date of the last modification is always accurate. This option permits more accurate synchronization of local files and their counterparts on the FTP site, but should not be used if the actual date/time of the local file’s download is signficant.
The /localdate option instructs Robo-FTP to update the last modified date and time of the server file to match the date and time of the corresponding local file that was just downloaded. The time of the file will be accurate to the minute (the seconds field is not updated). If the FTP site is hosted on a Unix system, the time saved for the server file is accurate only for files updated on the FTP site within the current year since the file time of older files is not available to Robo-FTP. The date of the last modification is always accurate. This option permits more accurate synchronization of server files and their counterparts on the local machine, but should not be used if the original date/time of the server file is signficant.
Using wildcard characters and the /subdirs option, a script may retrieve the entire contents of an FTP site directory and all subdirectories, and have a corresponding folder structure reproduced on the local PC. In the following example, all files with an extension of .xml in the current FTP site directory and all subdirectories are downloaded.
RCVFILE "*.xml" /subdirs
Consider the following example where all the files in the current FTP site directory and all subdirectories are downloaded and then deleted from the FTP site after a successful transfer.
RCVFILE "*.*" /subdirs /delete
Important For the /subdirs option to perform properly with wildcards, it is important that the contents of the FTP site directory structure not change (i.e., new files added or files deleted) while the RCVFILE command is active.
Important Relative path names are not permitted in the RCVFILE command when the /subdirs option is present. For example, "*.xml" is permitted, but "Site/*.xml" is not.
The /emptydirs and /flat options modify the default behavior of RCVFILE with the /subdirs option. With /emptydirs, empty directories found on the FTP site are not duplicated on the local PC. With /flat, all files found in directories and subdirectories on the FTP site are written to the current local working folder.
Related Command(s): SENDFILE, SYNC, WORKINGDIR See also: Using the %sitefile and %sitedir Variables, Using the %downloaderrors and %uploaderrors Variables |