[英]Windows batch Script Error
我是Windows批處理腳本編程的新手。 我修改了一個現有的腳本,當嘗試運行它時,出現如下錯誤。
( was unexpected at this time.
后來我做了一個bash -n腳本名稱,它給了我類似script_name.bat 15的錯誤:語法錯誤:got(,期望換行
第15行如下
for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j
您能幫我這個忙嗎..此腳本主要用於導入datastage作業。 使用Windows命令
請在下面找到我的完整代碼
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
rem Script Variables
set SVC_TIER=XXXXX
set ENG_TIER=XXXXX
set PROJECT=XXXX
set ISTOOL_PATH=C:\IBM\InformationServer11_3_1\Clients\istools\cli\
set DSCC_PATH=C:\IBM\InformationServer11_3_1\Clients\Classic\
set AUTH_PATH=C:\Users\User1\Documents\Deployment_scripts\
set AUTH_FILE=oneadr_authfile.txt
set LOG_PATH=C:\Users\User1\Documents\Deployment process\Deployment\
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.