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

Compare with Current View Page History

« Previous Version 10 Next »

Introduction

This is the first in a series of articles describing how to get started with using the JADE Client via its Command Line Interface and configuring simple file management tasks.

The articles in this series are:

  1. Getting Started and Downloading files
  2. Simple File Selection
  3. More Advanced File Selection
  4. File Transfer

  5. Checking files for completeness
  6. Public / Private Key Authentication

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.

Simple JADE file transfer operations - download by FTP and SFTP

Transferring the contents of a folder by FTP

In this example the contents of a folder on a remote host are downloaded from the SOS GmbH demonstration FTP server and saved on the local file system.

The full configuration for this operation is shown in the XML Editor screenshot below.

Configuration structure

The Configurations element shown has two child nodes Fragments and Profiles, each containing a different group of configuration elements.

  • The Fragments elements cover the protocol-specific parts of the configuration - in the current configuration these are that the protocol that is to be used, and the connection and authentication. 
    • Note that a file transfer operation usually requires two Fragments - one for the source part of the transfer and one for the target. However a target fragment is not required here as the the target is the local file system.
    • Any number of Fragments can be predefined within a configuration and specified as required using their name attribute - in the example configuration this is ftp_demo_sos-berlln. This predefinition of Fragments allows their reuse and keeps the configuration well structured.
  • The Profile elements contain the parameters that are specific to the current operation
    • the Operation to be carried out is copy,
    • the ftp_demo_sos-berlin Fragment that is to be used for the source part of the operation,
    • the files that are to be transferred (all) from the directory defined using  / file path,
    • the directory that files are to be transferred to: ${USERPROFILE}\jade_demo\a
      (on a Linux system the equivalent location would be ${HOME}/jade_demo/a ).
  • The ref attribute in the FTPFragmentRef element is used to specify the Fragment to be used - in this case for the source part of the operation.

The structure of the configuration is described in more detail in the JADE User Manual - Configuring and Running File Transfers article and its child articles.

Configuration Files

The configuration will be converted by default from the XML Editor's native XML format to the settings.ini format required for JADE up to versions 1.10 when the configuration is saved in the XML Editor.

The following code boxes can be opened to show the simple configuration described above in XML and in settings.ini formats:

Simple file transfer configuration in XML format
<?xml version="1.0" encoding="utf-8"?>
<Configurations xsi:noNamespaceSchemaLocation="http://www.sos-berlin.com/schema/jade/JADE_configuration_v1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Fragments>
    <ProtocolFragments>
      <FTPFragment name="ftp_demo_sos-berlin">
        <BasicConnection>
          <Hostname><![CDATA[test.sos-berlin.com]]></Hostname>
        </BasicConnection>
        <BasicAuthentication>
          <Account><![CDATA[demo]]></Account>
          <Password><![CDATA[demo]]></Password>
        </BasicAuthentication>
      </FTPFragment>
    </ProtocolFragments>
  </Fragments>
  <Profiles>
    <Profile profile_id="ftp_server_2_local">
      <Operation>
        <Copy>
          <CopySource>
            <CopySourceFragmentRef>
              <FTPFragmentRef ref="ftp_demo_sos-berlin" />
            </CopySourceFragmentRef>
            <SourceFileOptions>
              <Selection>
                <FileSpecSelection>
                  <FileSpec><![CDATA[.*]]></FileSpec>
                  <Directory><![CDATA[./]]></Directory>
                </FileSpecSelection>
              </Selection>
            </SourceFileOptions>
          </CopySource>
          <CopyTarget>
            <CopyTargetFragmentRef>
              <LocalTarget />
            </CopyTargetFragmentRef>
            <Directory><![CDATA[${USERPROFILE}\jade_demo\a]]></Directory>
          </CopyTarget>
        </Copy>
      </Operation>
    </Profile>
  </Profiles>
</Configurations>
Simple file transfer configuration in settings.ini format
[protocol_fragment_ftp@ftp_demo_sos-berlin]
protocol                            = ftp

host                                = test.sos-berlin.com
user                                = demo
password                            = demo

[ftp_server_2_local]
operation                           = copy

source_include                      = protocol_fragment_ftp@ftp_demo_sos-berlin
file_spec                           = .*
source_dir                          = ./

target_protocol                     = local
target_dir                          = ${USERPROFILE}\jade_demo\a

Example

The following profile from your settings file will be used to run the example on your computer:

ftp_server_2_local
[ftp_server_2_local]
;;
 operation               = copy
;;
 source_host             = test.sos-berlin.com
 source_protocol         = ftp
 source_port             = 21
 source_user             = demo
 source_password         = demo
 source_dir              = /
;;
 target_host             = localhost
 target_protocol         = local
 target_dir              = ${USERPROFILE}\jade_demo\a

The parameters listed above should not require further description and are the minimum that are required to copy files from the demo user's root directory on the remote source to a local target directory. By default JADE will download all the files it finds in the directory.

Run the example by entering the following in the command line:

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

Behavior

JADE will log onto the remote server and download all the files it finds in the source_dir folder before stopping.

Note that by default JADE will create the target folder and/or path if it does not exist and if JADE has the necessary permissions. It will also overwrite any files it finds in the target directory with the same names as files it is downloading.

Note also that the transfer mode JADE uses for FTP transfer can be specified using the transfer_mode parameter (not used in the example). This can be either ascii or binary (the default setting).

Transferring the contents of a folder by SFTP with password authentication

This example uses the second profile in our examples settings file, sftp_server_2_local_pass, which is quite similar to the ftp_server_2_local profile used in the previous example.

As the new profile name suggests, the SFTP protocol is used in this profile and authentication is by user/password. Key pair authentication is described later in this series of articles.

Example

The profile is included in the jade_settings_windows.ini file as follows:

[sftp_server_2_local_pass]
;;
 operation              = copy
;;
 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

Then call this profile by entering the following in the Windows command line:

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

Behavior

As with the FTP transfer profile, JADE will log onto the remote server and download all the files in the source_dir folder before stopping.

  • No labels