我正在处理一个批处理脚本,在该脚本中,我需要将所有Tableau工作簿保存在一个文件夹中,并在其中附加一组tabcmd发布参数,然后使用tabcmd执行发布命令。
下面是我的代码;
@ECHO OFF
CLS
ECHO **********************************************************************
SET /p folderPath= "Please enter the folder path where the workbooks are saved: "
ECHO '%folderPath%'
SET /p tabsvr_path= "Please enter path of Tableau Server bin directory: "
ECHO '%tabsvr_path%'
SET /p project_name= "Please enter the project name where the workbooks needs to be saved: "
ECHO '%project_name%'
ECHO **********************************************************************
ECHO *** Get all the txt files from the provided folder ***
ECHO **********************************************************************
cd %folderPath%
setlocal enableDelayedExpansion
set /a ID=1
for /f "tokens=1* delims=:" %%G in ('dir *.twb /b') do (
set filename[!ID!]=%%~G
set filefullPath[!ID!]=%%~fG
set /a ID+=1
)
set filefullPath
set filename
ECHO **********************************************************************
ECHO *** Get all the txt files from the provided folder ***
ECHO **********************************************************************
SET TAB_SERVER=http://domain.tableau.com
SET DB_USERNAME=ApplicationUser
SET DB_PASSWORD=@pp!User_!2#
SET TAB_USERNAME=AnalyticsUser
SET TAB_PASSWORD=Password
SET "RUN_CMD=tabcmd "
SET "PUB_SYN=publish ""
SET "FIRST_PARAM=" -n ""
SET "DBUSERNM=" --db-username ""
SET "DBPASS=" --db-password ""
SET WRKBKPROJ= %project_name%
SET "OTHER_PARAMS=" --save-db-password --project ""
SET "PARAM_CLOSE=" --tabbed""
set "x=1"
:SymLoop
if not defined filefullPath[%x%] goto :endLoop
set "EXEC_PATH=%tabsvr_path:"=%"
set "EXEC_PATH=%EXEC_PATH:<=^<%"
set "EXEC_PATH=%EXEC_PATH:>=^>%"
if "%EXEC_PATH:~0,2%"=="C:" (
if "%EXEC_PATH: =%"=="%EXEC_PATH%" (
set tabsvr_path=%EXEC_PATH%
) else (
set tabsvr_path=^"%EXEC_PATH%^"
)
)
REM ECHO %tabsvr_path%
CD /D %tabsvr_path%
ECHO **********************************************************************
ECHO *** Login into Specified Target Tableau Server ***
ECHO **********************************************************************
tabcmd login --no-certcheck -s %TAB_SERVER% -u %TAB_USERNAME% -p %TAB_PASSWORD%
ECHO **********************************************************************
CALL SET NEWWRKNAME=%FIRST_PARAM%%%filename[%x%]%%
CALL SET ARGS1=%DBUSERNM%%DB_USERNAME%%DBPASS%%DB_PASSWORD%%OTHER_PARAMS%%TAB_PROJECT%%PARAM_CLOSE%
REM ECHO %ARGS1%
call set ARGS0=%RUN_CMD%%PUB_SYN%%%filefullPath[%x%]%%
REM ECHO %ARGS0%
ECHO %ARGS0%%NEWWRKNAME%%ARGS1%
REM START /b /w /D %ARGS0%%NEWWRKNAME%%ARGS1%
SET /a "x+=1"
GOTO :SymLoop
:endLoop
echo "Done"
ECHO **********************************************************************
ECHO *** Logout of the Specified Target Tableau Server ***
ECHO **********************************************************************
tabcmd logout
ECHO **********************************************************************
pause
endlocal
cd/
cd /D %tabsvr_path%
以下是我面临的问题。
tabcmd发布“ c:\ Tableau Automation \ AC.twb” -n“ AC.twb” --db-用户名“ ApplicationUser” --db-密码“ @pp” --save-db-password-项目“” --tabbed”
有人可以让我知道如何修改脚本以获取整个密码以及调用tabcmd吗?