我对Windows批处理脚本编程非常陌生。我修改了一个现有的脚本,当尝试运行时,它给我一个错误,如下所示。
( was unexpected at this time.
后来我做了一个 bash -n 脚本名称,它给了我一个错误,如script_name.bat 15:语法错误:得到(,期望换行符
下面给出了第 15 行
for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j
请你帮帮我..此脚本主要用于导入数据阶段作业。使用视窗命令
请在下面找到我的完整代码
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
rem Script Variables
set SVC_TIER=XXXXX
set ENG_TIER=XXXXX
set PROJECT=XXXX
set ISTOOL_PATH=C:IBMInformationServer11_3_1Clientsistoolscli
set DSCC_PATH=C:IBMInformationServer11_3_1ClientsClassic
set AUTH_PATH=C:UsersUser1DocumentsDeployment_scripts
set AUTH_FILE=oneadr_authfile.txt
set LOG_PATH=C:UsersUser1DocumentsDeployment processDeployment
for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j
set strUnique=%ldt:~0,4%%ldt:~4,2%%ldt:~6,2%%ldt:~8,2%%ldt:~10,2%%ldt:~12,2%
set LOG_FILE=iis_01_import_%strUnique%.log
set LOG_FILE_COMPILE=iis_02_compilation_%strUnique%.log
set intExitCode=99
if "%1."=="." (
@echo Script Error: Import File info is empty. Usage ^<%0 isx_file^>
exit /B %intExitCode%
)
if not exist %1 (
@echo Script Error: File ^<%1^> does not exists
exit /B %intExitCode%
)
rem Checking import file type: isx or pkg
for /F "tokens=2 delims=^." %%f in ( "%1" ) do set strFileType=%%f
set strFileType=%strFileType: =%
if not %strFileType% ==isx (
if not %strFileType% ==pkg (
@echo Import file type not valid ^(it should be "isx" or "pkg" format^). Please, review file ^<%1^>
goto :EOF
)
)
@echo File to be imported into Datastage ^<%PROJECT%^> project: %1. Type of file: ^<%strFileType%^>
rem IS tool import code command
if %strFileType%==isx call %ISTOOL_PATH%istool.bat import -dom %SVC_TIER% -authfile %AUTH_PATH%%AUTH_FILE% -datastage %ENG_TIER%/%PROJECT% -archive %1 -replace 1> %LOG_PATH%%LOG_FILE% 2>&1
if %strFileType%==pkg call %ISTOOL_PATH%istool.bat deploy package -dom %SVC_TIER% -authfile %AUTH_PATH%%AUTH_FILE% -localfile %1 -datastage '-replace %ENG_TIER%/%PROJECT%' 1> %LOG_PATH%%LOG_FILE% 2>&1
@echo IStool return code: %ERRORLEVEL%
if not '%ERRORLEVEL%'=='0' (
@echo IS tool error message on Import process. Please, review %strFileType% file ^<%1^> and IS Tool logs.
goto :EOF
)
rem Exit codes:
rem 0 - Success
rem 1 - Warning
rem 2 - Partial failure
rem 3 - Import failed
rem 4 - Import preview failed
rem 5 - Invalid archive file
rem 6 - Error reading ImportOptions.json file
rem 7 - Error reading the response file.
rem 8 - The contents of the response file cannot be empty.
rem 9 - The -preview parameter is not supported with -responseFile.
rem 10 - Failed to connect to Information Server domain
rem 11 - Invalid command syntax
也许这个工具可以帮助你指出正确的方向:http://www.robvanderwoude.com/battech_batcodecheck.php