简体   繁体   English

Windows批处理脚本错误

[英]Windows batch Script Error

I am very new to windows batch script programming. 我是Windows批处理脚本编程的新手。 I modified an existing scripts and when try to run it is giving me an error as given below. 我修改了一个现有的脚本,当尝试运行它时,出现如下错误。

( was unexpected at this time.

Later I did a bash -n script name and its given me the error like script_name.bat 15: syntax error: got (, expecting Newline 后来我做了一个bash -n脚本名称,它给了我类似script_name.bat 15的错误:语法错误:got(,期望换行

Line 15 is given below 第15行如下

for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j

COuld you please help me on this ..This script is mainly used for importing the datastage jobs. 您能帮我这个忙吗..此脚本主要用于导入datastage作业。 using windows command 使用Windows命令

Please find my complete code below 请在下面找到我的完整代码

@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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM