1 Reply Latest reply on May 3, 2018 9:14 AM by Ciaran Bource

    Batch Script to run Data source refresh with tabcmd login

    Len Van Den Berg

      Hi all


      We have a number of batch scripts to run overnight for refreshing our data sources: a Daily (Weekday), a Weekend (Sunday) and a Monthly (Month End) script.

      The script does a set of tabcmd's including a tabcmd logout, followed by a tabcmd Login.


      I am testing a new functionality running on our Windows 2012R2 servers using a Logging capability so we can see when some scripts succeed or fail in a logfile.

      We use Tableau Server 10.0


      We have a Tableau Service account for running these batch scripts.

      When I test I get a real "hit and miss" scenario when logging in the svc account.


      This is a typical example of a possible refresh script:



      ::Create a log file containing todays date

      ::LogPath is the path to the folder where the log file will be saved

      ::LogFileName is a descriptive name that will be added after the date

      ::LogFileExt is the extension to be used

      ::======WEEKLY BATCH RUN=======SUNDAYS===FULL REFRESH==========


      set VERSION=10.0

      set BINPATH="E:\Program Files\Tableau\Tableau Server\%VERSION%\bin"

      cd /d %BINPATH%

      setlocal enabledelayedexpansion

      set LogPath=E:\TableauBatchFile\RefreshTask\BatchLogs\

      set LogFileExt=.log


      set dt=%date:~10,4%%date:~4,2%%date:~7,2%

      echo %dt%


      set LogFileName=%LogPath%WeeklyRefresh_%dt%%LogFileExt%


      echo ===== File output logged to %LogFileName%

      echo off

      tabcmd logout

      tabcmd login --no-certcheck -s "https://tableau.mygroup.net" --username svctab_1234--password mypasswd123! --site MYSITE

      echo =====Starting the Tableau WEEKLY Batch Run ==FULL REFRESH== for !DATE! !TIME!

      echo ========================================================================

      echo ========================================================================

      echo !DATE! !TIME!; Starting the Data Source Refresh Batch


      echo !DATE! !TIME!; Start Patient_Overview

      tabcmd refreshextracts --datasource "Patient_Overview" --project "Patient Reports" --no-certcheck

      echo !DATE! !TIME!; completed Patient_Overview


      ::followed by more 20+ jobs...


      echo !DATE! !TIME!======Completed the WEEKLY Data Source Refresh Batch====

      )>%LogFileName% 2>&1


      Now here is the deal - it seems Tableau schedules these refresh jobs. These are using the Login provided in the script.


      In the meantime I want to carry on testing some DAILY scripts.

      When I do a Tabcmd Logout and then again Tabcmd login with these credentials, I get this error in my log:



      ===== Creating new session

      =====     Server:   https://tableau.mygroup.net

      =====     Username: svctab_1234

      =====     Site:     MYSITE

      ===== Connecting to the server...

      ===== Signing in...

        *** Not authorized

      Invalid username or password. (errorCode=16)


      I am not able for the life of me to figure out why my creds will stop working and why I cannot log in to run this test script.

      Yet upon the first run I have no issues. The first run was successful and I could log in using tabcmd login in my script.

      Is this a Tableau Server thing?