tSystem to run unix commands with Tabcmd

Five Stars

tSystem to run unix commands with Tabcmd

Hi all,

 

I've made a talend job which automatically sends out tableau reports to our client partners in pdf format. The main component is a tSystem component, where I run the Tabcmd script. I developed the job in Windows environment, but the job will run in an Ubuntu machine. This is the script which runs perfectly in a Windows machine:

 

"cmd /c cd client_partner_reports & tabcmd login -s https://online.tableau.com -t sitename -u username -p password 
&
tabcmd get \"views/workbook/worksheet?Date%20Parameter%20="+ (String)globalMap.get("end_date") +"&Date%20Parameter%202=" + (String)globalMap.get("start_date") + "&someid=" + (String)globalMap.get("someid") +"\" -f \""+ (String)globalMap.get("name") + "_" + (String)globalMap.get("start_date") + "_" + (String)globalMap.get("end_date") +".pdf\""

I tried to make it Unix compatible by getting rid of the cmd /c cd client_partner_reports part of the script, and replacing & with ; , but it gives me this error: 

 

java.io.IOException: Cannot run program "tabcmd": error=2, No such file or directory

 

When I ran the same code in a terminal it ran fine, but inside a tsystem it gives me this error. Then I modified the script like this:

 

"/opt/tableau/tabcmd/bin/tabcmd login -s https://online.tableau.com -t sitename -u username -p password 
; 
/opt/tableau/tabcmd/bin/tabcmd get \"views/workbook/worksheet?Date%20Parameter%20="+ (String)globalMap.get("end_date") +"&Date%20Parameter%202=" + (String)globalMap.get("start_date") + "&someid=" + (String)globalMap.get("someid") +"\" -f \""+ (String)globalMap.get("name") + "_" + (String)globalMap.get("start_date") + "_" + (String)globalMap.get("end_date") +".pdf\""

If I run this, it gives me this error message: 

 

  *** Unrecognized option: -f

Again, if I run the code in a terminal, it downloads and saves the pdf. 

 

What is the error here? How can I make sure that I have a script which will run in a Unix machine too?


Accepted Solutions
Five Stars

Re: tSystem to run unix commands with Tabcmd

I used a single command option. I did however found a workaround, I have now two different tSystem components doing only a single command, and connected via onSubjobOK, now it runs perfectly.

View solution in original post


All Replies
Seven Stars

Re: tSystem to run unix commands with Tabcmd

Hi,

 

Did you check environment variables ? It's the best shot you have to figure out why it's not working.

Your tableau user might havee some variable declared.

Five Stars

Re: tSystem to run unix commands with Tabcmd

Thanks for the reply!
On the second script, I did specify the full path, but then it gave this error:
*** Unrecognized option: -f
Employee

Re: tSystem to run unix commands with Tabcmd

Hi,

 

    Your tSystem might be pointing to a different Unix directory. Could you please check the current directory by using pwd command?

 

    If its different from intended directory, please move to the right directory by using cd command.

 

    If its working fine from terminal, this could be the root cause.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

Five Stars

Re: tSystem to run unix commands with Tabcmd

Hi,
I set it up the home directory in the Talend component, so it is the intended directory. The issue is I believe that Talend interprets the tabcmd get command with the -f option somehow differently than when it is just put in a terminal.
Employee

Re: tSystem to run unix commands with Tabcmd

Hi,

 

   Could you please add the command in a shell script .sh file and try to run the command through that file?

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

Five Stars

Re: tSystem to run unix commands with Tabcmd

In the meantime I found out that the error is probably related to having multiple commands executed. When I create a job in Linux with only a tSystem component, and I put “echo test1 ; echo test2” I would expect the output to be
test1
test2
But instead of that it is: echo test1 ; echo test2. So it seems that Talend doesn’t recognize the ; as an end of a command.

[cid:image001.png@01D57DFA.8AC83410]

[cid:image002.png@01D57DFA.8AC83410]
Employee

Re: tSystem to run unix commands with Tabcmd

Hi,

 

    Could you please share a screenshot to get an understanding of how you are calling the shell commands using tSystem?

 

     Are you using "Use Array Command" option?

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

Five Stars

Re: tSystem to run unix commands with Tabcmd

I used a single command option. I did however found a workaround, I have now two different tSystem components doing only a single command, and connected via onSubjobOK, now it runs perfectly.

View solution in original post

Employee

Re: tSystem to run unix commands with Tabcmd

Hi,

 

     You can do that way. You can also go for array command option too. 

 

     Since the issue is resolved, could you please mark the post as closed? It will help others during their reference.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 3

Read about some useful Context Variable ideas

Blog