This is the second in a series of articles describing how to get started with using the the JADE Client via its Command Line Interface.
The articles in this series are:
- Getting Started and Downloading files
- More Advanced File Selection
- Checking files for completeness
- Public / Private Key Authentication
For setting-up and running the examples see Using the tutorials with the JADE Client Command Line Interface
File Selection - Simple Examples
Before starting to transfer files JADE reads the contents of the folder specified using one or more child elements of the Selection parameter.
In the examples in first article in this series a default setting, that all the files in the source directory will be downloaded, was used: .* .
In this example the source directory file list will be filtered so that only specific files are transferred.
File Name Filtering and Recursive File Transfer
The following profile shows how JADE can be used to:
- Filter the names of files to be transferred using a regular expression
- Transfer files from sub-directories recursively
The ftp_demo_sos-berlin ProtocolFragment used in the Client Command Line Interface - Getting Started tutorial will be reused.
Duplicate the ftp_server_to_local Profile and the name of the new instance changed to ftp_server_to_local_select_recursive.
In the new Profile, the following changes have been made:
The value of the file_spec defines the regular expression used to filter file names
- A recursive child element has been added to the FileSpecSelection element and its value set to true (the default value is false).
- The source_dir parameter has also been changed to:
Call this profile by entering the following in the command line:
The relevant file structure on the source server is:
- JADE will download the test_1.txt from the /rec folder on the server and ignore the test.txt file whose name does not match with the file_spec regular expression.
- JADE will create a /sd folder in the target a directory if this folder does not already exist.
- It will the open the /rec/sd sub-folder on the server, create a corresponding folder on the target and download the test_2.txt file to this folder.
Behavior with DisableErrorOnNoFilesFound = true
The default behavior of JADE is to throw an error if a file transfer is attempted and no files are found. The DisableErrorOnNoFilesFound element is used to allow JADE to attempt a file transfer without an error being generated if no files are found. This behavior can be useful when, for example, when polling for files.
The DisableErrorOnNoFilesFound element is specified as a Directives child element, the next screenshot shows how this element is integrated in a configuration:
The effect of setting the DisableErrorOnNoFilesFound element can be demonstrated if, for example, the FileSpec regular expression in the Profile element to, for example
^text\.txt$ and recalling the operation.
The file transfer will now end with an Exit-Code 99.
If, however, the DisableErrorOnNoFilesFound element is set to true, JADE will not throw an error.
- The meaning of the values true and false for the DisableErrorOnNoFilesFound element are the opposite to the meaning for the element's
settings.inifile predecessor, force_files.
The JADE Client can handle files with zero bytes in a number of ways, depending on the setting used for the TransferZeroByteFiles parameter, which is also specified as a child of the Directives element.
The default TransferZeroByteFiles setting is true. The screenshot below shows how this element is integrated in a duplicate of the ftp_server_2_local file transfer profile described in the first tutorial in this series.
In its original configuration, the ftp_server_2_local profile transfers six files from the SOS test server to the local file system. One of these files - ./test_4.txt - has zero bytes and can be used to demonstrate the use of the TransferZeroByteFiles parameter.
The screenshot also shows the relevant extract from the parameter reference for the TransferZeroByteFiles element with a description of the meaning of the different values the TransferZeroByteFiles element can have.
This profile is called on Windows systems using the following command:
- With the zero_byte_transfer parameter set to relaxed (i.e. with the file_spec and zero_byte_transfer parameters set as listed above) the test_4.txt zero byte file will not be downloaded.
- Changing the zero_byte_transfer setting to no by commenting in/out the appropriate line in the profile and rerunning the example will:
- cause the the test_4.txt file to be ignored as with the relaxed setting and
- cause an error to be raised if no files with more than zero bytes are found - i.e. if no files are to be transferred.
This can be demonstrated by activating the alternative file_spec regex (^test_\.txt$) setting which will only match for the zero byte file.
- A setting of zero_byte_transfer = strict will cause an error to be raised if any zero byte files are matched