Executing a Linux command with a pipe using a tSystem component

Overview

This article explains how to execute a Linux command containing a pipe with a tSystem component. Potential problems you may encounter and troubleshooting suggestions are also included.

 

Environment

This procedure was written with:

  • Product version: Talend Open Studio for DI 5.0-r72978 and Talend Open Studio for DI 5.1-r79249

  • JDK version: Sun JDK build 1.6.0_26-b03

  • Operating system: Ubuntu 11.10

 

Procedure

Pipes are used in Bash scripts. You will encounter an error when executing a Linux command with a pipe in a tSystem component, although it does work in a Linux terminal. For example, this command:

"cat /home/pedro/log1 >> /home/pedro/log2"

Will produce this error:

nosuchfile.png

 

This is because tSystem component cannot handle a pipe directly. To fix this problem, use the suggested release-specific procedures below, or upgrade to version 5.1 or higher.

 

Talend Studio v5.0-r72978 or previous versions

  1. Create a new job, then drag and drop a tSystem component from the Palette to the Job editor.
  2. Enter the following Java code in the Command field.

    new String[]{"/bin/bash","-c","cat /home/pedro/log1 >> /home/pedro/log2"}

     1_023.png

 

Talend Studio v5.1-r79249 or higher versions

Since Talend Studio 5.1, a new feature Use Array Command is provided. This feature allows you to set an array of commands. Below is an example that introduces this feature:

  1. Create a new job, then drag and drop a tSystem component from the Palette to the Job editor.
  2. Select the Use Array Command box, then add the commands as seen below in the Command table.

     2_021.png

Version history
Revision #:
2 of 2
Last update:
‎06-23-2017 01:00 AM
Updated by:
 
Labels (1)
Tags (1)