July 30, 2023

tSCPFileExists – Docs for ESB 7.x

tSCPFileExists

Verifies the existence of a file on the defined SCP server.

tSCPFileExists checks, over a fully encrypted channel,
if a file exists on a remote host.

tSCPFileExists Standard properties

These properties are used to configure tSCPFileExists running in the Standard Job framework.

The Standard
tSCPFileExists component belongs to the Internet family.

The component in this framework is available in all Talend
products
.

Basic settings

Host

SCP IP address.

Listening port number of the SCP server.

 

SCP user name.

 

SCP authentication method.

 

SCP password.

To enter the password, click the […] button next to the
password field, and then in the pop-up dialog box enter the password between double quotes
and click OK to save the settings.

 

File path on the remote directory.

 

Name of the file to check.

 

Advanced settings

tStatCatcher Statistics

Select this check box to collect log data at the component level.

Global Variables

Global Variables

ERROR_MESSAGE: the error message generated by the
component when an error occurs. This is an After variable and it returns a string. This
variable functions only if the Die on error check box is
cleared, if the component has this check box.

FILENAME: the name of the file being processed. This is a
Flow variable and it returns a string.

STATUS: the execution result of the component. This is an
After variable and it returns a string.

A Flow variable functions during the execution of a component while an After variable
functions after the execution of the component.

To fill up a field or expression with a variable, press Ctrl +
Space
to access the variable list and choose the variable to use from it.

For further information about variables, see
Talend Studio

User Guide.

Usage

Usage rule

This component is typically used as a single-component subJob but
can also be used with other components.

Handling a file using SCP

In this scenario, a six-component Job checks if a defined file exists in a specified
directory on a remote SCP server, and returns a message to indicate the result of the
verification. If the file doesn’t exist in that directory, the Job will put the local
file to the SCP server, and then get the file from the SCP server to another defined
local directory to verify that the file has been uploaded correctly.

tSCPFileExists_1.png

Dropping and linking the components

  1. Add the following six components by typing their names on the design
    workspace or dropping them from the Palette
    to the design workspace: tSCPConnection,
    tSCPFileExists, tJava, tSCPPut, tSCPGet, and tSCPClose.
  2. Connect the tSCPConnection component to
    the tSCPFileExists component using a
    Trigger > On
    Subjob Ok
    connection.
  3. Connect the tSCPFileExists component to
    the tJava component using a Trigger > On Component
    Ok
    connection, and to the tSCPPut component using a Trigger > Run if
    connection.
  4. Connect the tSCPPut component to the
    tSCPGet component using a Trigger > On Subjob
    Ok
    connection.
  5. Connect the tSCPGet component to the
    tSCPClose component using a Trigger > On Subjob
    Ok
    connection.

Configuring the tSCPConnection component

  1. Double-click the tSCPConnection component
    to open its Basic settings view.

    tSCPFileExists_2.png

  2. Enter the host name or IP address of the SCP server and the port number in
    the corresponding field.
  3. Enter the user name used for connection in the Username field.
  4. Select Password from the Authentication method drop-down list.
  5. Click the […] button next to the
    Password text box, then in the pop-up
    Enter a new password dialog box,
    enter the password between double quotes and click OK to save the change.

    tSCPFileExists_3.png

Configuring file existence verification

  1. Double-click the tSCPFileExists component
    to open its Basic settings view.

    tSCPFileExists_4.png

  2. Select the Use an existing connection
    check box and then select the connection you have configured from the
    Component List.
  3. In the Filename field, enter the name of
    the file to be checked between double quotes. In this example, it is
    “testscp.txt”.
  4. Double-click the tJava component to open
    its Basic settings view.

    tSCPFileExists_5.png

  5. In the Code field, enter the following
    code:

  6. Select the Component tab and click the
    If connection to open its Basic settings view.

    tSCPFileExists_6.png

  7. In the Condition field, enter the
    following code:

    This way, if the file doesn’t exist in the defined directory, the rest of
    the Job will be executed.

Configuring the tSCPPut component

  1. Double-click the tSCPPut component to
    open its Basic settings view.

    tSCPFileExists_7.png

  2. Select the Use an existing connection
    check box and then select the connection you have configured from the
    Component List.
  3. Click the [+] button to add one row in
    the Filelist table, and enter the full
    local path of the file to be uploaded in the corresponding Source column. In this example, it is “D:/SCPPut/testscp.txt”.

Configuring the tSCPGet component

  1. Double-click the tSCPGet component to
    open its Basic settings view.

    tSCPFileExists_8.png

  2. Select the Use an existing connection
    check box and then select the connection you have configured from the
    Component List.
  3. In the Local directory field, enter or
    click the […] button to browse to the
    directory under which the file will be stored. In this example, it is
    “D:/SCPGet”.
  4. Select append from the Overwrite or Append drop-down list.
  5. Click the [+] button to add one row in
    the Filelist table, and then enter the path
    of the file to be retrieved from the SCP server in the corresponding
    Source column. In this example, it is
    “./testscp.txt”.

Configuring the tSCPClose component

  1. Double-click the tSCPClose component to
    open its Basic settings view.

    tSCPFileExists_9.png

  2. Select the connection you have configured from the Component List.

Executing the Job

  1. Press Ctrl+S to save the Job.
  2. Make sure the file testscp.txt exists
    in the local directory D:/SCPPut, and
    does not exist in the local directory D:/SCPGet and the home directory of the SCP server.
  3. Press F6 to run the Job.

    tSCPFileExists_10.png

    The file verification information is displayed on the Run console.
  4. Go to the local directory D:/SCPGet and
    the home directory of the SCP server, you will see the file testscp.txt there.

Document get from Talend https://help.talend.com
Thank you for watching.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x