You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Introduction

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.

Articles in this series are:

  1. Getting Started and Downloading files
  2. Simple File Selection
  3. More Advanced File Selection
  4. Checking files for completeness
  5. Public / Private Key Authentication

File Selection - Simple Examples

Before starting to transfer files JADE reads the contents of the folder specified using the source_dir parameter.

In the examples in first article in this series a default setting, that all the files in the source directory will be downloaded, applied.

In this article the source directory file list will be filtered so that only specific files are transferred.

File Name Filtering and Recursive File Transfer

In the examples JADE was used to transfer all the files from the directory specified in the source_dir parameter.

However, 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

Example

In the profile listed below, two new parameters have been added to the sftp_server_2_local_pass example from above:

  • file_spec defines the regular expression used to filter file names

  • recursive specifies whether the transfer should be carried out recursively (the default value is false)

The source_dir parameter has also been changed to:

  • /rec

The relevant file structure on the source server is:

  • /
    • /rec
      test.txt
      test_1.txt
      • /sd
        test_2.txt
[sftp_server_2_local_select_recursive]
;;
 operation              = copy
 file_spec              = ^test_.\.txt$
 recursive              = true
;;force_files           = false
;;
 source_host            = test.sos-berlin.com
 source_protocol        = sftp
 source_ssh_auth_method = password
 source_port            = 22
 source_user            = demo
 source_password        = demo
 source_dir             = /rec
;;
 target_host            = localhost
 target_protocol        = local
 target_dir             = ${USERPROFILE}\jade_demo\a

Call this profile by entering the following in the command line:

Windows
jade.cmd -settings="%USERPROFILE%\jade_demo\jade_settings.ini" -profile="sftp_server_2_local_select_recursive"

Behavior

  • 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 force_file = true

As mentioned above, the default value for the force_file parameter is true, meaning that even if this parameter is not specified, the JADE engine will throw an error if no match is found.

This can be demonstrated by changing the file_spec regular expression in the profile to, for example ^text\.txt$ and recalling the profile.

If, however, the force_file = true parameter in the example profile is commented in, JADE will not throw an error.

Zero-Byte Files

The JADE Client can filter files with zero bytes using the zero_byte_transfer parameter.

Example

The test_4.txt file on our test server has zero bytes and can be used to demonstrate the use of the zero_byte_transfer parameter.

Note that alternative values of the file_spec and zero_byte_transfer parameters are included in the example profile but have been commented out (using ;;). These alternative values allow the functioning of the zero_byte_transfer parameter to be properly demonstrated. The default zero_byte_transfer setting is yes.

[sftp_server_2_local_zero_byte]
;;
 operation              = copy
 file_spec              = ^test_[0-9]\.txt$
;;file_spec              = ^test_[4]\.txt$
;;zero_byte_transfer     = no
 zero_byte_transfer     = relaxed
;;zero_byte_transfer     = strict
;;
 source_host            = test.sos-berlin.com
 source_protocol        = sftp
 source_ssh_auth_method = password
 source_port            = 22
 source_user            = demo
 source_password        = demo
 source_dir             = /
;;
 target_host            = localhost
 target_protocol        = local
 target_dir             = ${USERPROFILE}\jade_demo\a

Call the profile using:

jade.cmd -settings="%USERPROFILE%\jade_demo\jade_settings.ini" -profile="sftp_server_2_local_zero_byte"

Behavior

  • 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.
  • A setting of zero_byte_transfer = no 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_[4]\.txt$) 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
  • No labels