One Star

Issue while running Linux commands from tSystem

Hi,
I am writing a command: "echo Hello >> /root/test.txt" in a tSystem component of Talend Job in Linux. It simply prints "Hello >> /root/test.txt", and the output is not redirected to "/root/test.txt".
The same command when run from Linux redirects output "Hello" to the file test.txt
Is there any other way to write such a command? Can somebody help regarding this.
Thanks and Regards,
Diwakar
5 REPLIES
One Star

Re: Issue while running Linux commands from tSystem

hi,
did you try to create a script with your string as parameter.
One Star

Re: Issue while running Linux commands from tSystem

hi,
did you try to create a script with your string as parameter.

Hi,
Thanks, That would work, but i don't want to use scripts.
Is that a bug in Talend, or is there any other way to achieve this using tSystem only?

Regards,
Diwakar
Six Stars

Re: Issue while running Linux commands from tSystem

The tSystem currently implements the Runtime.Exec(String command), and not Runtime.exec(String[] cmdarray) which would pass a stack of commands. Also, using redirects such as >> or > is fun stuff handled by bash itself. You could try modifying the component to implement the cmdarray or, my preferred method is to use java.io.BuffererReader and BufferedWriter to read and write to an interactive shell session since there are many subtle behaviors that are implmented by the shell itself that will not work through direct system calls as expected.
One Star

Re: Issue while running Linux commands from tSystem

hi,
I am writing a command:  mysqldump -h "+context.host+"-u "+context.root+"-p"+context.host+"  "+context.database+"> "+context.out_path_name+"
in tsystem for linux through talend this command run but not creating dumpfile & not show any error.
while The same command when run from Linux mysqldump -h localhost -u root -proot  bennet_bi > d:bennet_bi.sql
its creat dump file.
Regards
Ravindra
One Star

Re: Issue while running Linux commands from tSystem

hi,
i want to create job in which we give database name from csv file & job create mysql dump backup  for all given dataabse.
how can i do it,
thanks
ravindra