Introduction
This is the fourth in a series of articles describing how to get started with using the the JADE Client via its Command Line Interface.
JADE Tutorials List
JADE Client Command Line Interface
- Getting Started and Downloading files
- Simple File Selection
- More Advanced File Selection
- Checking files for completeness
- Public / Private Key Authentication
- Transfer via a Jump Host / DMZ
JADE Background Service
Prerequisites
See the Using the tutorials with the JADE Client Command Line Interface article for guidelines to setting up and running the tutorial examples.
Instructions for installing, configuring and using the XML Editor can be found in the XML Editor series of articles.
Download file
The configuration described in this tutorial can be downloaded and then directly opened in the XML Editor using the following link:
- sos-berlin_demo_2_local_select_adv.xml
File Transfer Examples
Renaming files
The following example combines two renaming possibilities:
- Renaming files
- Adding a date-stamp to file names
See the JADE Parameter Reference - Rename article for a full list of the renaming possibilities.
Example
The file name part(s) to be replaced is/are defined in the replacing parameter with round brackets () and the new part(s) in the replacement parameter, separated by semi-colons.
The example shows a two-part substitution:
- test will be replaced with file_ and
- '_' with the current date in the format specified.
Configuration structure
ProtocolFragment
There are no ProtocolFragments specified in this configuration as both source and target are on the local file system.
Profile
The meaning of the three elements required to specify renaming - Rename, ReplaceWhat and ReplaceWith elements should be self-explanatory.
FileSpec
The value of the FileSpec element was changed to ^test_.\.txt$
. Five files will be found in the transfer source directory.
Polling Elements
The Polling parent element is added as a child of the SourceFileOptions element. In the example profile shown in the XML Editor screenshot below the function of the three poll_* parameters should be self-explanatory but the following should be noted:
poll_interval - is specified in seconds (only integer values)
poll_timeout - is specified in minutes (only integer values)
poll_minfiles - optional - can only be used together with poll_timeout
XML Editor Configuration
The Profile Code
The following code boxes can be opened to show the Profile and ProtocolFragments used in this example in XML and in settings.ini
formats.
Running the Profile
This profile is called on Windows systems using the following command, depending on the JADE version being used:
jade.cmd -settings="%USERPROFILE%\jade_demo\local_2_local_select_adv.xml" -profile="local_2_local_replace_datestamp" jade.cmd -settings="%USERPROFILE%\jade_demo\local_2_local_select_adv.ini" -profile="local_2_local_replace_datestamp"
Behavior
The five test_*.txt files in the the a folder will be copied to the b folder and parts of their names will be replaced as described above.
File cumulation
JADE can cumulate the contents of individual files to a single target file:
- Files matching the file_spec regular expression are cumulated together into a new file
- The original files can be deleted if required
- There is not a de-cumulate parameter available at the moment
Example
The example profile downloads the five text_*.txt files from our demo server and adds their contents successively to a cumulative file.
The cumulative file is then given the name specified in the cumulative_file_name parameter in the profile.
The text specified in the cumulative_file_separator parameter is incorporated in the cumulative file between the contents of the individual files.
The order in which the files are added to the cumulative file is not fixed but depends on the order in which the files arrive on the local file system.
[sftp_server_2_local_cumulate] ;; operation = copy file_spec = ^test_.\.txt$ ;; cumulate_files = true cumulative_file_name = text-files.txt cumulative_file_separator = --- File: %{SourceFileName} --- ;;cumulative_file_delete = true ;; 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
Run the example using:
jade.cmd -settings="%USERPROFILE%\jade_demo\jade_settings.ini" -profile="sftp_server_2_local_cumulate"
Behavior
Opening the cumulative file text-files.txt in a text editor after transfer has been completed shows the order in which individual files were added to the cumulative file.
Note that this will not necessarily follow the order in which transfer of individual files was started.