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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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?

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

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

9 Replies
rmartin2
Creator II
Creator II

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.

Anonymous
Not applicable
Author

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

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

Anonymous
Not applicable
Author

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.
Anonymous
Not applicable
Author

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

Anonymous
Not applicable
Author

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]
Anonymous
Not applicable
Author

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

Anonymous
Not applicable
Author

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.
Anonymous
Not applicable
Author

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