SENDFILE Send one or more files |
Top Previous Next |
When connecting to a HTTP/HTTPS site, only the following options are valid with the SENDFILE command: /allowerrors, /archive, /as, /delete, /lower, /nospaces, /timeout=xx, /upper
This script command uploads one or more files to an FTP site. Upon completion of the command, the %uploadcount script variable contains the total number of files uploaded and the %uploadsize script variable contains the size in bytes of the most recent file uploaded. If the /allowerrors option is specified, the count of any file I/O errors is recorded I the %uploaderrors variable
When uploading, the FTP site automatically creates a file with the same name as the original. This behavior may be modified. When the /as option is used, the uploaded file is saved using the specified name; when the /ap option is used with non-secure FTP sites the uploaded file is appended to an existing file of the same or a different name.
For example, the following command sends a file named “file name” from Robo-FTP’s current working folder to the current directory on the FTP site:
SENDFILE "file name"
When relative path names are specified, as in the following command, a file is sent from the specified local folder relative to the Robo-FTP current working folder and is stored in the current directory on the FTP site. In the following example, a file named "file name" is uploaded from a local folder named “localdir” relative to Robo-FTP’s current working folder and saved as "file name" in the current FTP site directory.
SENDFILE "localdir\file name"
Multiple files may be sent by using wildcard characters (*, ?) in the [ file name ]. Consider the following example in which all the files in a particular directory are sent to the FTP site.
SENDFILE "c:\My Data\*" /timeout=30
Important Automatic transmission of multiple files may also be accomplished using the GETNEXTFILE command and a conditional looping structure within a script file.
The /archive option automatically moves a local file to an archive folder defined using the ARCHIVEDIR script command after it has been successfully sent. If a file by the same name exists in the archive folder, it is overwritten. Do not confuse this with the /ifarchive option which is used to send only local file(s) that have the archive (backup) file attribute set.
The /copydirs option modifies the destination archive folder in the same manner that it modifies the destination folder on the remote server.
The /delete option automatically deletes a local file after it has been successfully sent. The /subdirs option may be used to send the entire contents of a local folder and all subfolders, and have a corresponding directory structure reproduced on the FTP site. In the following example, all files with an extension of .html in the My Site folder and all subfolders are uploaded to the FTP site.
SENDFILE "c:\My Site\*.html" /subdirs
Consider the following example where all the files in a specified folder and all subfolders are uploaded and then deleted after being sent successfully.
SENDFILE "c:\My Data\*" /subdirs /delete
Important For the /subdirs option to perform properly with wildcards, it is important that the contents of the local PC folder structure not change (i.e., new files added or files deleted) while the SENDFILE command is active.
Important Relative path names are not permitted in the SENDFILE command when the /subdirs option is present. For example, "c:\My Data\*" is permitted, but "My Data\*" is not.
The /emptydirs and /flat options modify the default behavior of SENDFILE with the /subdirs option. With /emptydirs, empty directories found on the local PC are not duplicated on the FTP site. With /flat, all files found in folders and subfolders on the local PC are written to the current directory on the FTP site.
The following example command results in a local file being sent and saved as a different file name on an FTP site.
SENDFILE "c:\My Data\test" /as "test001" /timeout=30
There are two forms of the SENDFILE command that may be used to append data to a file on an FTP sites (including FTPS and SFTP sites.) The form using the /append option results in a file being appended to a file of the same name on the FTP site. The form using the /ap option may be used to append to a file with different name on the FTP site. If the file does not exist on the FTP site in either case, the file is created. The following examples show both syntax.
// append to an FTP site file named "test" SENDFILE "c:\My Data\test" /append
// append to an FTP site file named "newtest" SENDFILE "c:\My Data\test" /ap "newtest" /timeout=30
The /iflarger, /ifnsamesz, /ifnewer, and /ifnotexist options may be used to control if FTP site files are to be overwritten when sent by Robo-FTP. These options are 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 remote server. This is important for accurate file date and time stamp comparisons. For example, if you are in the Central U.S. timezone and the remote server is located in the Eastern U.S. timezone then files created at the exact same time will appear one hour older on the remote server. The syntax for subtracting one hour from the server time is as follows:
SENDFILE "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 following syntax adds two hours to the server time:
SENDFILE "serverfile" /ifnewer /tz=+2
The /integrity option enables file integrity checking to be used during the upload. 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 from the current working directory are upload to the server with file integrity checking using the SHA256 algorithm.
SENDFILE "*" /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 untransmitted portion of the file is sent and is appended to the incomplete portion currently saved on the FTP site. If Robo-FTP determines that it is not safe to resume a transfer, the SENDFILE command fails if /resume is specified, or the entire file is retransmitted if /resumeany is specified.
The /nospaces option causes Robo-FTP to convert space characters found in local folder and file names to underscores before creating corresponding directories on the FTP site and when sending files. This resolves an incompatibility in file naming between Windows and Unix (Unix does not allow spaces in file names). For example, the following command would result in a file named my_test_file.txt being stored on the FTP site.
SENDFILE "c:\my test file" /nospaces
The /lower and /upper options cause Robo-FTP to convert local folder and file name(s) specified by [ file name ] and [ new file ] to lower or upper case, respectively, before creating corresponding directories on the FTP site and when sending files.
The /maxrate option causes Robo-FTP to limit the bandwidth used when uploading 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 an upload 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. For example, to limit an upload to 100Kbps, you’d specify the following command:
SENDFILE "c:\my test file" /maxrate=100
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 uploaded. The time of the file will be accurate to the minute (the seconds field is not updated). This option permits more accurate synchronization of local files and their counterparts on the FTP site, but should not be used if the original date/time of the local file 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 uploaded. The time of the file will be accurate to the minute (the seconds field is not updated). 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.
The /blocksize option changes the default read size of the SENDFILE command from 32,000 bytes to the specified value. In the following example, the block size is changed to 64,000 bytes. A higher or lower number may improve throughput performance based on experimentation in your network.
SENDFILE "c:\my test file" /blocksize=64000
The /type option specifies the type of file transfer to perform. If this option is used while connected to a Managed Site, the specified value overrides the site's Default Transfer Mode. EBCDIC file transfer mode is not permitted unless IBM Host Features mode is enabled and should only be attempted after verifying /type=ascii produces unsatisfactory results with a given site. When connected to an SFTP site, using /type=ascii results in carriage return/line feed (DOS line ending) being converted to line feed (Unix line ending.) This is only useful when the remote system uses Unix-style line endings. The %servertype internal variable may help determine if this option is appropriate for your connection.
Related Command(s): RCVFILE, SYNC, WORKINGDIR See also: Using the %nextfile, %nextfolder, and %nextpath Variables, Using the %downloaderrors and %uploaderrors Variables
|