Earlier this week I was given the following task:

“Write me a little TABCMD script to publish a .twbx from my machine to a tableau online account”

At only the start of Data School week 3, I had no idea what one of these was, let alone how to formulate one. Furthermore, the name “TABCMD script” certainly suggested to me that it would be complicated to do so.

But I did get there eventually and consequently, I’ll describe the learning process that I undertook to complete this, 95% of which was research and understanding; 5% was the actual application.

So, the first port of call was to identify what exactly a tabcmd script is. My current understanding is that it is an automated function run through windows that will perform admin tasks behind the scenes of Tableau.

Sounds handy, right?

Next, I had to break down the request and identify exactly what the tasks were. To do this I looked at the step-by-step, or should I say click-by-click approach of what one would do when manually publishing a workbook to Tableau online:

  1. Select server menu option
  2. Select publish
  3. Login
  4. Give it a name
  5. Publish

Following this mind mapping, I then had to identify the associated commands for the script. To facilitate this Tableau provides a useful reference page:

https://onlinehelp.tableau.com/current/server/en-us/tabcmd_cmd.htm

When writing the script, the first two stages can be skipped and it’s possible to begin with logging in.

To initiate this first command, we need to specify in the script – what it is we are doing, where to sign in to and what the username and password is to do that. This materialises as follows:

tabcmd login -s https://online.tableau.com. -t 'thesiteID' -u 'YourUsername' -p 'YourPassword'

Key

-s = server (in this case Tableau online)

-t = site ID (used in the server to distinctively recognise the specific site)

-u = username

-p = password

The second and final part is the actual publishing stages – having just gained access to where you wish the file to be stored. A new command is necessary to identify the process of publishing. After which specification of where the file to be published lives is required, followed by the name you wish to give it. In script format, this is how it looks:

tabcmd publish "fullfilepath.twbx" -n "File_Name"

Key

-n = name to give to file

 

There you have it, not as complicated as expected, two lines of generic script that perform a cumbersome admin task for you:

tabcmd login - s https://online.tableau.com. -t 'siteID' - u 'Username' - p 'Password'
tabcmd publish "fullfilepath.twbx" -n "File_Name"

Just fill in the quote marked sections with your individual information and give it a try.