Using Tabcmd to generate PDF’s, PNG’s, emails and alerts

This document covers many different subjects, all related to using Tabcmd – a new command-line utility as part of the 5.0 release. While we have made every effort to ensure clean, portable, and easy to understand documentation, due to the highly variable nature of this subject, we advise that you carefully review the information. Please do not try to cut and paste entire sections or commands ‘as-is’, because that will probably not work.

1.  Installation

Tabcmd requires Tableau Server – it will do nothing by itself. The installer for Tabcmd is located inside of any Tableau Server installation, at the following default location:

TABLEAU\Tableau Server\5.0\extras\TabcmdInstaller.exe

You can run the installation and choose default settings. Afterwards, Tabcmd will be a command that is available in the system path. Also note that Tabcmd does not have to be installed on the same machine as Tableau Server. This makes it highly useful from an administrative and scheduling perspective.

Once installed, let’s jump right in with some simple syntax examples. We assume a Tabcmd installation path of c:\tli\Tabcmd for the duration of this document.

2.  Getting and saving PDF and PNG files:

Open a command prompt and login to your Tableau server with Tabcmd:

Tabcmd login -s http://tableauserver:80 -u admin -p admin

Replace the http://host:port with your specific hostname and port. Replace the “admin” username and “admin” password with a valid Tableau server username and password – it needs to be someone with publishing rights. If it works, it should look like this:

C:\tli>Tabcmd login -s http://tableauserver:80 -u admin -p admin

===== Creating new session

===== Server: http://tableauserver:80/

===== Username: admin

===== Connecting to server...

===== Logging in...

===== Login Succeeded.

This will leave you in a logged-in state for the duration of the command line session. (AKA windows shell, AKA ‘dos prompt’)

(see next page)

Now that we have a session, let’s get a PDF of one of the shipping examples. If you did not install the shipping Tableau Server examples, you will need to change the following line accordingly:

Tabcmd get /views/Wow/SummaryReports.pdf

If it works, you will end up with a PDF file “SummaryReports.pdf” in the current working directory. Otherwise, a detailed error will be thrown indicating the nature of the problem. If you add:

-f progressReport.pdf

To the command, it will create a file called “progressReport.pdf” instead of using the default name.

While Tabcmd by itself cannot send emails, it is very easy to add this via scripting. There are many applications and scripting languages available with which you can combine the printing automation of Tabcmd with practically any other logic you see fit. We have provided two additional examples to illustrate this.

3.  Sending Email

For this next example, we installed a piece of email shareware called febootimail .exe (do a web search on ‘febootimail’ for more info) This allowed us full control over aspects of the email generation. Here is a simple three-line example:

Tabcmd login -s http://tableauserver:80 -u admin -p admin

Tabcmd get / views/Wow/SummaryReports.pdf -f progressReport.pdf

febootimail.exe -SMTP yourSMTPhost.yourcompany.com -TO "; ;" -FROM -SUBJECT "Generated Tableau View - Tableau Server Automated Alert System (TSAAS)" -ATTACH " C:\Program Files\Tableau\Tableau Command Line\progressReport.pdf" –BODY “this is the text of the body”

If you have installed febootimail and review its help files, you will note the following:

1.  instead of manually typing in email recipients using the –TO tag, you can refer to a file, 2. instead of manually typing in the email body using the –BODY tag, you can specify an –HTMLFILE tag, and 3. You can attach multiple files.

This provides quite a bit of control over the Tableau generation and email process. Many other applications and scripting languages will have this type of support, which means the possibilities are endless!

(see next page)

4.  Sending formatted email with a Tableau picture embedded directly into the email body

An even more interesting example is when you combine the fact that Tabcmd can generate PNG files with the fact that febootimail.exe can send html emails. Per the help for febootimail, the html file needs to be in the same directory as febootimail. We were able to create a script that looks like this:

Tabcmd login -s http://tableauserver:80 -u admin -p admin

Tabcmd get / views/Wow/SummaryReports.png -f progressReport.png

febootimail.exe -SMTP yourSMTPhost.yourcompany.com -TO "; ;" -FROM -SUBJECT "Generated Tableau View - Tableau Server Automated Alert System (TSAAS)" - -HTMLFILE "emailbody.html"

Notice how we have replaced the BODY tag with an HTMLFILE tag. Because we can auto-generate a PNG image, we can then reference that image inside the body of an html email template. Here is a simple version of this html file:

<html>

<head<title>Email Alert</title</head>

<body<img src=”progressReport.png”</body>

</html>

5.  Conclusion

Some of the elements we looked at in this document include:

a.  generating PDF’s and PNG’s from a command line using Tabcmd

b.  sending emails from a command line using febootimail.exe

These two simple concepts help to illustrate the point that there is no limit to how complex and powerful this type of automation can be. You can use a wide variety of tools and languages to achieve great results with Tableau Server.