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. The following command does not work with a tSystem component, although it does work in a Linux terminal.

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

Use the following release specific workarounds:

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"}

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 introduces this feature:

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

Common Error: "No such file or directory"

You will encounter the below error when executing a Linux command with pipe on a tSystem component as follows:

 

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

No such file or directory

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

Version History
Revision #:
1 of 1
Last update:
‎04-17-2017 07:38 PM
Updated by:
 
Labels (1)
Contributors