Windows-batch-scriptfejl

Indlæg af Hanne Mølgaard Plasc

Problem



Jeg er meget ny til Windows batch script programmering. Jeg har ændret et eksisterende script, og når jeg prøver at køre, giver det mig en fejl som angivet nedenfor.


( was unexpected at this time.


Senere gjorde jeg et bash -n script navn og det gav mig fejlen som script\_name.bat 15: syntaksfejl: fik (forventer Newline


Linje 15 er angivet nedenfor


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


Du kan hjælpe mig med dette. Dette script bruges hovedsageligt til at importere datastagejobene. ved hjælp af Windows-kommando


Find venligst min komplette kode nedenfor


@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

Bedste reference


Måske kan dette værktøj hjælpe dig med at henvise dig i den rigtige retning: http://www.robvanderwoude.com/battech\_batcodecheck.php[4]