Most of us knows that we can use Talend's in built component tSystem to run windows batch or Linux/Unix commands. However, It doesn't work, when we try to run any Unix or Linux command which includes redirection of output in to file. Talend has provided a work around for executing Unix and Linux with pipe or Redirection.
For Example: Following command to compress the file will not work in tSystem folder.
grep -c abc.csv > mycompressed_abc.gz
To execute a Unix/Linux command having redirection use any of the following methods:
1. Using Single Command: In the component properties of tSystem, enter the following command in the Command text box:
3. Last method is to write the Unix or Linux script in a script file and call the script using tSystem component.
e.g. we will create a script test.sh with following contents
grep -c abc.csv > mycompressed_abc.gz
enter the following command in the Command text box to execute a script:
"sh -c test.sh"
So these are the three methods which which we can run Linux/Unix commands having pipe or redirection in it. Please let me know, if you guys have used any other method. Looking forward for your comments.
For Example: Following command to compress the file will not work in tSystem folder.
grep -c abc.csv > mycompressed_abc.gz
To execute a Unix/Linux command having redirection use any of the following methods:
1. Using Single Command: In the component properties of tSystem, enter the following command in the Command text box:
e.g. we will create a script test.sh with following contents
grep -c abc.csv > mycompressed_abc.gz
enter the following command in the Command text box to execute a script:
"sh -c test.sh"
So these are the three methods which which we can run Linux/Unix commands having pipe or redirection in it. Please let me know, if you guys have used any other method. Looking forward for your comments.
how to run a script with commandline arguments in talend?
ReplyDelete