Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

Not able to run Linux command using tSystem Component

Hello All,
I am running following command in TOS using tSystem Component. But It is not performing the task rather displaying the contents in the console when its executable is run.
sed 's/_DEV/_PROD/' input_file > output_file
I am passing input_file and output_file from context params.
Please help.
Labels (2)
11 Replies
Anonymous
Not applicable

try this:
sed 's/_DEV/_PROD/' " + context.input_file + " > " + context.output_file
Anonymous
Not applicable

I think the issue is because you are using redirection (">") in the command. Try using the below Java code in the command box:
new String[]{"/bin/bash","-c","sed 's/_DEV/_PROD/' input_file > output_file"}

Click here for more details on the same
Anonymous
Not applicable

Hello Vikram,
I want to add custom headers (only 1 line) in all my target txt files. I am using windows remote connection in that I use talend 5.6 linux box. I use following code but unable to add custom headers.
Code in tsystem(Use line Command)-
new String[]{"/bin/bash tempath='/home/UserName/Desktop/CI0.txt' Filepath='/home/UserName/Desktop/HeaderCi.csv'  for line in $temppath; do cat $Filepath $line>tmp && mv tmp $line done"}
Error-
Exception in component tSystem_1
java.io.IOException: Cannot run program "/bin/bash tempath='/home/UserName/Desktop/CI0.txt' Filepath='/home/UserName/Desktop/HeaderCi.csv'  for line in $temppath; do cat $Filepath $line>tmp && mv tmp $line done" (in directory "/home/UserName/Desktop/CI"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1042)
Note:
If I tick mark or not tick mark "Use Home directory"  , in both condition I get same error.
I use following command too but not working:
"sed -i '1s/^/'Custome_Header_Name'\n/' CI*.txt"
"echo 'Custome_Header_Name' | cat - CI0.txt > temp && mv temp CI0.txt"
echo "$(echo 'Custome_Header_Name' | cat - CI0.txt)" > CI0.txt

Please guide me.
Anonymous
Not applicable

Dear All,
Can anyone please guide me for same , as I am unable to resolve this problem.
Regards
Rsh
Anonymous
Not applicable

Dear Team,
Please help me out as I am running out of time..
Regards
RSH
Anonymous
Not applicable

Hi RSH
Could you try to run this command in Linux prompt to see it works before you use tSystem?
Best regards
Shong
Anonymous
Not applicable

Hello Shong,
Thanks a lot for your reply.
Your suggestion to check in Linux prompt, Can you please tell me how to do it? This is first time I am using remote->linux box-> talend(5.6) hence not sure how to use Linux.
Shong , can you please suggest steps to check it.
If you are talking about to check my code using CMD(PUTTY), then YES, my code works and I get my expected result in all my 100+ files.
Shong sir, can you please check my code in your environment if possible, because since last week I am working on same thing and not getting any result.
Please guide.
Regards
RSH
Anonymous
Not applicable

Hi RSH
Yes, I meant to run this command in Linux CMD to make sure there is no syntax error in the command. Can you please upload a screenshot to show how your command works in Linux CMD.
Best regards
Shong
Anonymous
Not applicable

I have 3 files in my drive i.e.
1. text file in which we get target output data from oracle source. File name is CI0.txt
2. Headerfile in which we have header format which is useful for froent end team (to load file in front end).File name is HeaderCI.csv
3. Script which has code to add header file data in target CI0.txt file. 
Now I have to run script from Putty. (Screen shot in attachment.)
0683p000009MERg.png
Even if we try normal single command like: sed -i '1s/^/'Custome_Header_Name'\n/' CI*.txt
This code works in putty but not working in Talend.
0683p000009ME66.png
Talend Job Snapshot:
I am using same directory, same path, but normally It gives me an error "NO SUCH FILE DIRECTORY" or syntax error even though it shows me OK status.
0683p000009ME7D.png
Sir, can you please let me know where I made an error.
Regards
RSH