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.
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
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
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
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.)
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.
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.
Sir, can you please let me know where I made an error.
Regards
RSH