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 |
|
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
FILENAME: the name of the file being processed. This is a
STATUS: the execution result of the component. This is an A Flow variable functions during the execution of a component while an After variable To fill up a field or expression with a variable, press Ctrl + For further information about variables, see |
Usage
Usage rule |
This component is typically used as a single-component subJob but |
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.
Dropping and linking the components
-
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. -
Connect the tSCPConnection component to
the tSCPFileExists component using a
Trigger > On
Subjob Ok connection. -
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. -
Connect the tSCPPut component to the
tSCPGet component using a Trigger > On Subjob
Ok connection. -
Connect the tSCPGet component to the
tSCPClose component using a Trigger > On Subjob
Ok connection.
Configuring the tSCPConnection component
-
Double-click the tSCPConnection component
to open its Basic settings view. -
Enter the host name or IP address of the SCP server and the port number in
the corresponding field. - Enter the user name used for connection in the Username field.
- Select Password from the Authentication method drop-down list.
-
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.
Configuring file existence verification
-
Double-click the tSCPFileExists component
to open its Basic settings view. -
Select the Use an existing connection
check box and then select the connection you have configured from the
Component List. -
In the Filename field, enter the name of
the file to be checked between double quotes. In this example, it is
“testscp.txt”. -
Double-click the tJava component to open
its Basic settings view. -
In the Code field, enter the following
code:12System.out.println((String)globalMap.get("tSCPFileExists_1_FILENAME"));System.out.println((String)globalMap.get("tSCPFileExists_1_STATUS")); -
Select the Component tab and click the
If connection to open its Basic settings view. -
In the Condition field, enter the
following code:1!((String)globalMap.get("tSCPFileExists_1_STATUS")).equals("File exists.")This way, if the file doesn’t exist in the defined directory, the rest of
the Job will be executed.
Configuring the tSCPPut component
-
Double-click the tSCPPut component to
open its Basic settings view. -
Select the Use an existing connection
check box and then select the connection you have configured from the
Component List. -
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
-
Double-click the tSCPGet component to
open its Basic settings view. -
Select the Use an existing connection
check box and then select the connection you have configured from the
Component List. -
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”. - Select append from the Overwrite or Append drop-down list.
-
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
-
Double-click the tSCPClose component to
open its Basic settings view. - Select the connection you have configured from the Component List.
Executing the Job
- Press Ctrl+S to save the Job.
-
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. -
Press F6 to run the Job.
The file verification information is displayed on the Run console.
-
Go to the local directory D:/SCPGet and
the home directory of the SCP server, you will see the file testscp.txt there.