命令在提示符下有效,但在批处理中无效
Command works from prompt but not from batch
当我从命令提示符 运行 以下命令时,它完美执行:-
C:\ouaf\CCB2402\bin>call splenviron -e CCB2402
Version ................ (OUAFVERSION) : 4.2.0.2.0
Database Type ............... (OUAFDB) : oracle
ORACLE_SID ............. (ORACLE_SID) : CCB_DB
等...
但是当我从批处理文件中 运行 做同样的事情时,它给了我一个错误。
批处理文件内容:-
cd C:\ouaf\CCB2402\bin
call splenviron -e CCB2402
给出的错误:-
Error detected while calling splstdinclude.cmd
splenviron.cmd的内容:-
@echo off
REM #
REM #% DocInfo: see the file docinfo.txt for instructions on how
REM #% DocInfo: to use this file format for self documenting scripts.
REM #
REM #% PROGRAM: splenviron.cmd
REM #% PURPOSE: Initialise environment variables
REM #% USAGE: splenviron.cmd -e <environment> [-c <command>] [-h] [-q] [-v]
REM #% USAGE: -e <environment>
REM #% USAGE: environment name in field of /etc/cistab
REM #% USAGE: which also has an entry in ENVIRON.INI
REM #% USAGE: -c <command>
REM #% USAGE: command to run at end of script. Default is ksh
REM #% USAGE: -q
REM #% USAGE: dont show output from any commands in this script
REM #% USAGE: ( it will however show output from anything specified by -c
REM #% USAGE: -v <verbose>
REM #% USAGE: -h
REM #% USAGE: help
REM #% DIST: release
REM #
if /I "%SPLDEBUG%" EQU "Y" @echo on
:START
set SCRIPTNAME=%0
for /f %%I in ('echo %0') do set SCRIPTDIR=%%~dpI
if /I "%1" EQU "" goto USAGE
set SPLCOMMAND=
set SPLENVIRON=
set VERBOSE=
set SPLQUITE=
:GETARG
if /I "%1" EQU "" goto NOMOREARGS
if /I "%1" EQU "-h" goto USAGE
if /I "%1" EQU "-e" if not defined SPLENVIRON set SPLENVIRON=%2
if /I "%1" EQU "-c" if not defined SPLCOMMAND set SPLCOMMAND=%2
if /I "%1" EQU "-v" if not defined VERBOSE set VERBOSE=Y
if /I "%1" EQU "-q" if not defined SPLQUITE set SPLQUITE=Y
shift
goto GETARG
:NOMOREARGS
if not defined SPLENVIRON goto USAGE
if /I "%SPLENVIRON%" EQU "" goto USAGE
REM # **************************************************************
REM # **
REM # ** MAIN PART OF SCRIPT FILE
REM # **
REM # **************************************************************
:INIT
REM ---------------------------------------------------
REM Get SPLEBASE from CISTAB file
REM ---------------------------------------------------
set CISTABFILE=%SYSTEMDRIVE%\spl\etc\cistab
if not exist %CISTABFILE% echo Unable to find CISTAB file %CISTABFILE%.&&goto EXITWITHERROR
findstr /i /c:"%SPLENVIRON%:" %CISTABFILE% >nul
if ERRORLEVEL 1 echo Environment %SPLENVIRON% is not in CISTAB file %CISTABFILE%.&&goto EXITWITHERROR
for /f "delims=: tokens=1,2,3,4,5,6" %%i in ('findstr /i /c:"%SPLENVIRON%:" %CISTABFILE%') do set SPLEBASE=%%j:%%k
if not defined SPLEBASE echo Unable to set SPLEBASE&&goto EXITWITHERROR
if not exist %SPLEBASE% echo SPLEBASE directory %SPLEBASE% does not exist&&goto EXITWITHERROR
REM ---------------------------------------------------
REM Get SPLOUTPUT from CISTAB file
REM ---------------------------------------------------
for /f "delims=: tokens=1,2,3,4,5,6" %%i in ('findstr /i /c:"%SPLENVIRON%:" %CISTABFILE%') do set SPLOUTPUT=%%l:%%m
if not defined SPLOUTPUT echo Unable to set SPLOUTPUT&&goto EXITWITHERROR
if not exist %SPLOUTPUT% echo SPLOUTPUT directory %SPLOUTPUT% does not exist&&goto EXITWITHERROR
set SPLAPP=%SPLOUTPUT%
REM ---------------------------------------------------
REM Set PERLLIB and ANT_HOME
REM ---------------------------------------------------
REM # Setup Perllib to include OUAF supplied PM modules.
set ENVFILE=%SPLEBASE%\etc\ENVIRON.INI
for /f "delims== tokens=1,2" %%i in ('type %ENVFILE% ^| findstr /i /c:"ORACLE_CLIENT_HOME="') do set ORACLE_CLIENT_HOME=%%j
set PERL_HOME=%ORACLE_CLIENT_HOME%\perl
set PERLLIB=%PERL_HOME%\lib;%PERL_HOME%\site\lib;%SPLEBASE%\bin\perllib
set PERL5LIB=%PERL_HOME%\lib;%PERL_HOME%\site\lib;%SPLEBASE%\bin\perllib
echo %PATH% | findstr /I "%PERL_HOME%\bin" > nul
if ERRORLEVEL 1 set PATH=%PERL_HOME%\bin;%PATH%
:SETANT
set ANT_HOME=%SPLEBASE%\product\apache-ant
echo %PATH% | findstr /I "%ANT_HOME%\bin" > nul
if ERRORLEVEL 1 set PATH=%ANT_HOME%\bin;%PATH%
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k ANT_OPT_MIN') do set ANT_OPT_MIN=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k ANT_OPT_MAX') do set ANT_OPT_MAX=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k ANT_ADDITIONAL_OPT') do set ANT_ADDITIONAL_OPT=%%I
set CALC_ANT_OPT_MIN=
set CALC_ANT_OPT_MAX=
if "%ANT_OPT_MIN%" EQU "0" goto SKIP_ANT_OPT_MIN
set CALC_ANT_OPT_MIN=-Xms%ANT_OPT_MIN%M
:SKIP_ANT_OPT_MIN
if "%ANT_OPT_MAX%" EQU "0" goto SKIP_ANT_OPT_MAX
set CALC_ANT_OPT_MAX=-Xmx%ANT_OPT_MAX%M
:SKIP_ANT_OPT_MAX
set ANT_OPTS=%CALC_ANT_OPT_MIN% %CALC_ANT_OPT_MAX% %ANT_ADDITIONAL_OPT%
:SETUPSPLVARS
REM ---------------------------------------------------
REM Set environment variables
REM ---------------------------------------------------
echo %PATH% | findstr /I "%SPLEBASE%\bin" > nul
if ERRORLEVEL 1 set PATH=%SPLEBASE%\bin;%PATH%
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k FW_VERSION_NUM') do set FW_VERSION_NUM=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k SPLWAS') do set SPLWAS=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k CMPDB') do set CMPDB=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k SPLSYSTEMLOGS') do set SPLSYSTEMLOGS=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k SPLADMIN') do set SPLADMIN=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k SPLADMINGROUP') do set SPLADMINGROUP=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k WEB_SERVER_HOME') do set WL_HOME=%%I
set SPLBUILD=%SPLEBASE%\cobol\build
set SPLSOURCE=%SPLEBASE%\cobol\source
set SPLRUN=%SPLEBASE%\runtime
set SPLSYSTEMLOGS=%SPLEBASE%\logs\system
echo %PATH% | findstr /I "%SPLRUN%" > nul
if ERRORLEVEL 1 set PATH=%SPLRUN%;%PATH%
REM
REM Setup which compiler is to be used. Only supported option is microfocus
set SPLCOMP=microfocus
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k WEB_ISEXPANDED') do set WEB_ISEXPANDED=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k SPLApp') do set SPLApp=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k appViewer') do set appViewer=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k XAIApp') do set XAIApp=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k help') do set help=%%I
REM Setup display bill ini file - DOC1
set ONLINEBILLINI=%SPLEBASE%\etc\billdirfile.ini
set ONLINEDOCINI=%SPLEBASE%\etc\doc1dirfile.ini
:SETUPWEBAPPSERVER
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k JAVA_HOME') do set JAVA_HOME=%%I
if not exist %JAVA_HOME%\bin\java.exe echo ERROR - %JAVA_HOME%\bin\java.exe file does not exists. Exiting.&&goto EXITWITHERROR
echo %PATH% | findstr /I "%JAVA_HOME%\bin" > nul
if ERRORLEVEL 1 set PATH=%JAVA_HOME%\bin;%PATH%
if /I "%SPLWAS%" EQU "WLS" goto AFTERSETUPWEBAPPSERVER
echo ERROR - Only Weblogic is supported on Windows for OUAF. Exiting.&&goto EXITWITHERROR
:AFTERSETUPWEBAPPSERVER
:SETUPDB
goto SETUP%CMPDB%
echo ERROR - Cannot find DB setup routine. Exiting.&&goto EXITWITHERROR
:SETUPMSSQL
goto AFTERSETUPDB
:SETUPORACLE
REM We will gather the basic Database Home
for /f "delims=`" %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k ORACLE_CLIENT_HOME') do set ORACLE_HOME=%%~sI
if not defined ORACLE_HOME echo ERROR - environment variable ORACLE_HOME should be set prior to OUAF operation. Exiting.&&goto EXITWITHERROR
if not exist %ORACLE_HOME% echo ERROR - ORACLE_HOME %ORACLE_HOME% directory does not exist. Exiting.&&goto EXITWITHERROR
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k ORACLE_SID') do set ORACLE_SID=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k NLS_LANG') do set NLS_LANG=%%I
for /f %%I in ('call perl -e"$a=uc \"%NLS_LANG%\";print $a;"') do set NLS_LANG=%%I
set NLS_DATE_FORMAT=YYYY-MM-DD
set NLS_SORT=BINARY
goto AFTERSETUPDB
:AFTERSETUPDB
:SETUPCOBOL
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k RJVM') do set RJVM=%%I
if /I "%RJVM%" EQU "false" goto AFTERSETUPCOBOL
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k COBMODE') do set COBMODE=%%I
REM Set needed variables for COBOL Installations:
for /f "delims=`" %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k CHILD_JVM_JAVA_HOME') do set CHILD_JVM_JAVA_HOME=%%~sI
for /f "delims=`" %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k COBDIR') do set COBDIR=%%~sI
set SPLCOBCPY=%SPLSOURCE%\cm;%SPLEBASE%\services;%SPLSOURCE%
:SETUPMICROFOCUSNETEXPRESS
if not exist "%COBDIR%"\bin\cblrtss.dll goto SETUPMICROFOCUSAPPSERVER
echo %PATH% | findstr /I %COBDIR%\bin > nul
if ERRORLEVEL 1 set PATH=%COBDIR%\bin;%SPLRUN%;%PATH%
goto AFTERSETUPCOBOL
:SETUPMICROFOCUSAPPSERVER
if not exist %COBDIR%\cblrtss.dll echo Unable to find %COBDIR%\bin\cblrtss.dll nor %COBDIR%\cblrtss.dll. Please check your COBOL installation. Exiting.&&goto EXITWITHERROR
echo %PATH% | findstr /I %COBDIR% > nul
if ERRORLEVEL 1 set PATH=%COBDIR%;%SPLRUN%;%PATH%
goto AFTERSETUPCOBOL
:AFTERSETUPCOBOL
:CHECKENNVARS
REM # Check environment setup and readability of directories.
call %SPLEBASE%\bin\splstdinclude.cmd SPLcheckenvvars
if ERRORLEVEL 1 echo Error detected while calling splstdinclude.cmd.&&goto EXITWITHERROR
if /I "%SPLQUITE%" EQU "Y" goto AFTERQUITE
echo Version ................ (OUAFVERSION) : %FW_VERSION_NUM%
echo Database Type ............... (OUAFDB) : %CMPDB%
if /I "%CMPDB%" EQU "oracle" echo ORACLE_SID ............. (ORACLE_SID) : %ORACLE_SID%
if /I "%CMPDB%" EQU "oracle" echo NLS_LANG ................. (NLS_LANG) : %NLS_LANG%
echo Environment Name ....... (SPLENVIRON) : %SPLENVIRON%
echo Environment Code Directory (SPLEBASE) : %SPLEBASE%
echo App Output Dir - Logs ... (SPLOUTPUT) : %SPLOUTPUT%
echo Build Directory .......... (SPLBUILD) : %SPLBUILD%
echo Runtime Directory .......... (SPLRUN) : %SPLRUN%
echo Cobol Copy Path ......... (SPLCOBCPY) : %SPLCOBCPY%
:AFTERQUITE
if /I "%VERBOSE%" NEQ "Y" goto AFTERVERBOSE
echo Running on Operating SYSTEM (OS) : %OS%
echo Running on command interpreter (COMSPEC) : %COMSPEC%
echo Java Version
java -version
echo Perl Version
perl -V
:AFTERVERBOSE
cd /d %SPLEBASE%
if not defined CMENV goto AFTERCMENV
if exist %CMENV% call %CMENV%
:AFTERCMENV
if exist %SPLEBASE%\scripts\cm\cmenv.cmd call %SPLEBASE%\scripts\cm\cmenv.cmd
if /I "%SPLCOMMAND%" NEQ "" call %SPLCOMMAND%
goto ENDOFBAT
:USAGE
echo USAGE:
echo USAGE: %SCRIPTNAME% is the install program for Oracle application installations
echo USAGE:
echo USAGE: %SCRIPTNAME% -e environment [-c command] [-h]
echo USAGE: -e environment
echo USAGE: environment name in first field of cistab file
echo USAGE: which also has an entry in ENVIRON.INI
echo USAGE: -c command
echo USAGE: command to run at end of script
echo USAGE: -h
echo USAGE: help
echo USAGE:
goto EXITWITHERROR
:EXITWITHERROR
exit /B 1
goto ENDOFBAT
:ENDOFBAT
splstdinclude.cmd
的内容
REM #
REM #% DocInfo: LEAVE THE BELOW TWO LINES IN THE RESULTANTSHELL SCRIPT
REM #% DocInfo: see the file docinfo.txt for instructions on how
REM #% DocInfo: to use this file format for self documenting scripts.
REM #
REM #% PROGRAM: splstdinclude.cmd
REM #% PURPOSE: Common functions used in most SPL scripts
REM #% DESCRIPTION: Common functions used in most SPL scripts
REM #% USAGE: call splstdinclude.cmd arg where arg1 is the function name
REM #% USAGE: additional args can be passed to the function using
REM #% USAGE: arg1, arg2, ... , arg5
REM #% DIST: release
REM #% MODHISTORY: 000101:DC:Created
REM #% MODHISTORY: 00
REM #
REM #
REM #---------------------------------------------------------------------------
REM #
:START
if /I "%1" EQU "" echo Function name not provided.&&goto EXITWITHERROR
set FUNCTIONNAME=%1
for /f "delims=~" %%I in ('echo %2') do set PARM1=%%~I
for /f "delims=~" %%I in ('echo %3') do set PARM2=%%~I
for /f "delims=~" %%I in ('echo %4') do set PARM3=%%~I
for /f "delims=~" %%I in ('echo %5') do set PARM4=%%~I
for /f "delims=~" %%I in ('echo %6') do set PARM5=%%~I
goto %FUNCTIONNAME%
REM #---------------------------------------------------------------------------
REM # start of this function
REM #---------------------------------------------------------------------------
:SPLCHECKENVVARS
REM # The Following Variables are required to be set before splenviron.sh is even started.
if not defined SPLOUTPUT echo Environment variable SPLOUTPUT is not defined.&&goto EXITWITHERROR
if not exist %SPLOUTPUT% echo Unable to find directory %SPLOUTPUT%.&&goto EXITWITHERROR
if not defined JAVA_HOME echo Environment variable JAVA_HOME is not defined.&&goto EXITWITHERROR
if not defined SPLENVIRON echo Environment variable SPLENVIRON is not defined.&&goto EXITWITHERROR
if not defined SPLEBASE echo Environment variable SPLEBASE is not defined.&&goto EXITWITHERROR
if not exist %SPLEBASE%\bin echo Unable to find directory %SPLEBASE%\bin.&&goto EXITWITHERROR
for /f %%I in ('call perl -e"$a=lc "%CMPDB%";print $a;"') do set CMPDB=%%I
if not defined SPLCOMPLOG goto AFTERSPLCHECKENVVARS
:AFTERSPLCHECKENVVARS
goto ENDOFBAT
REM #---------------------------------------------------------------------------
REM # end of this function
REM #---------------------------------------------------------------------------
REM #---------------------------------------------------------------------------
REM # start of this function
REM #---------------------------------------------------------------------------
:LOG
REM # The Following Variables are required to be set before splenviron.sh is even started.
if not defined SPLCOMPLOG echo Environment variable SPLCOMPLOG is not defined.&&goto EXITWITHERROR
if not defined PARM1 set PARM1=
if /I "%PARM2%" EQU "-q" call perl -e"use SPL::splLog;my $log=SPL::splLog->new($ENV{'SPLCOMPLOG'});$log->info('-q', '%PARM1%');"
if /I "%PARM2%" NEQ "-q" call perl -e"use SPL::splLog;my $log=SPL::splLog->new($ENV{'SPLCOMPLOG'});$log->info('%PARM1%');"
:AFTERLOG
goto ENDOFBAT
REM #---------------------------------------------------------------------------
REM # end of this function
REM #---------------------------------------------------------------------------
:EXITWITHERROR
exit /B 1
:ENDOFBAT
似乎程序在将错误级别设置为 1 后退出。有人可以帮我解决这个问题吗?
好的,潜在原因:splstdinclude.cmd
可能根本没有改变错误级别。 splenviron.cmd
在调用 splstdinclude.cmd
之前做的最后一件事是如果 findstr 设置了错误级别则调整路径。
我猜你 运行 的命令提示路径中有 COBDIR,但双击 bat 文件却没有。
您可以通过在 call %SPLEBASE%\bin\splstdinclude.cmd SPLcheckenvvars
命令的任一侧添加 echo %errorlevel%
来检查这一点。
原因是你的批次延期了!
来自Difference .bat vs .cmd
.cmd enables built-in commands to change Errorlevel to 0 on success.
当你直接调用你的 .cmd 时这有效,所以错误级别将在 set CMPDB=%%I
命令后重置为 0。
但是,当您从 .bat 文件调用它时,它不再重置,即使代码仍然包含在 .cmd 文件中,它也是使用 .bat 逻辑执行的。
所以解决方案应该是将 .bat 也重命名为 .cmd
当我从命令提示符 运行 以下命令时,它完美执行:-
C:\ouaf\CCB2402\bin>call splenviron -e CCB2402
Version ................ (OUAFVERSION) : 4.2.0.2.0
Database Type ............... (OUAFDB) : oracle
ORACLE_SID ............. (ORACLE_SID) : CCB_DB
等...
但是当我从批处理文件中 运行 做同样的事情时,它给了我一个错误。 批处理文件内容:-
cd C:\ouaf\CCB2402\bin
call splenviron -e CCB2402
给出的错误:-
Error detected while calling splstdinclude.cmd
splenviron.cmd的内容:-
@echo off
REM #
REM #% DocInfo: see the file docinfo.txt for instructions on how
REM #% DocInfo: to use this file format for self documenting scripts.
REM #
REM #% PROGRAM: splenviron.cmd
REM #% PURPOSE: Initialise environment variables
REM #% USAGE: splenviron.cmd -e <environment> [-c <command>] [-h] [-q] [-v]
REM #% USAGE: -e <environment>
REM #% USAGE: environment name in field of /etc/cistab
REM #% USAGE: which also has an entry in ENVIRON.INI
REM #% USAGE: -c <command>
REM #% USAGE: command to run at end of script. Default is ksh
REM #% USAGE: -q
REM #% USAGE: dont show output from any commands in this script
REM #% USAGE: ( it will however show output from anything specified by -c
REM #% USAGE: -v <verbose>
REM #% USAGE: -h
REM #% USAGE: help
REM #% DIST: release
REM #
if /I "%SPLDEBUG%" EQU "Y" @echo on
:START
set SCRIPTNAME=%0
for /f %%I in ('echo %0') do set SCRIPTDIR=%%~dpI
if /I "%1" EQU "" goto USAGE
set SPLCOMMAND=
set SPLENVIRON=
set VERBOSE=
set SPLQUITE=
:GETARG
if /I "%1" EQU "" goto NOMOREARGS
if /I "%1" EQU "-h" goto USAGE
if /I "%1" EQU "-e" if not defined SPLENVIRON set SPLENVIRON=%2
if /I "%1" EQU "-c" if not defined SPLCOMMAND set SPLCOMMAND=%2
if /I "%1" EQU "-v" if not defined VERBOSE set VERBOSE=Y
if /I "%1" EQU "-q" if not defined SPLQUITE set SPLQUITE=Y
shift
goto GETARG
:NOMOREARGS
if not defined SPLENVIRON goto USAGE
if /I "%SPLENVIRON%" EQU "" goto USAGE
REM # **************************************************************
REM # **
REM # ** MAIN PART OF SCRIPT FILE
REM # **
REM # **************************************************************
:INIT
REM ---------------------------------------------------
REM Get SPLEBASE from CISTAB file
REM ---------------------------------------------------
set CISTABFILE=%SYSTEMDRIVE%\spl\etc\cistab
if not exist %CISTABFILE% echo Unable to find CISTAB file %CISTABFILE%.&&goto EXITWITHERROR
findstr /i /c:"%SPLENVIRON%:" %CISTABFILE% >nul
if ERRORLEVEL 1 echo Environment %SPLENVIRON% is not in CISTAB file %CISTABFILE%.&&goto EXITWITHERROR
for /f "delims=: tokens=1,2,3,4,5,6" %%i in ('findstr /i /c:"%SPLENVIRON%:" %CISTABFILE%') do set SPLEBASE=%%j:%%k
if not defined SPLEBASE echo Unable to set SPLEBASE&&goto EXITWITHERROR
if not exist %SPLEBASE% echo SPLEBASE directory %SPLEBASE% does not exist&&goto EXITWITHERROR
REM ---------------------------------------------------
REM Get SPLOUTPUT from CISTAB file
REM ---------------------------------------------------
for /f "delims=: tokens=1,2,3,4,5,6" %%i in ('findstr /i /c:"%SPLENVIRON%:" %CISTABFILE%') do set SPLOUTPUT=%%l:%%m
if not defined SPLOUTPUT echo Unable to set SPLOUTPUT&&goto EXITWITHERROR
if not exist %SPLOUTPUT% echo SPLOUTPUT directory %SPLOUTPUT% does not exist&&goto EXITWITHERROR
set SPLAPP=%SPLOUTPUT%
REM ---------------------------------------------------
REM Set PERLLIB and ANT_HOME
REM ---------------------------------------------------
REM # Setup Perllib to include OUAF supplied PM modules.
set ENVFILE=%SPLEBASE%\etc\ENVIRON.INI
for /f "delims== tokens=1,2" %%i in ('type %ENVFILE% ^| findstr /i /c:"ORACLE_CLIENT_HOME="') do set ORACLE_CLIENT_HOME=%%j
set PERL_HOME=%ORACLE_CLIENT_HOME%\perl
set PERLLIB=%PERL_HOME%\lib;%PERL_HOME%\site\lib;%SPLEBASE%\bin\perllib
set PERL5LIB=%PERL_HOME%\lib;%PERL_HOME%\site\lib;%SPLEBASE%\bin\perllib
echo %PATH% | findstr /I "%PERL_HOME%\bin" > nul
if ERRORLEVEL 1 set PATH=%PERL_HOME%\bin;%PATH%
:SETANT
set ANT_HOME=%SPLEBASE%\product\apache-ant
echo %PATH% | findstr /I "%ANT_HOME%\bin" > nul
if ERRORLEVEL 1 set PATH=%ANT_HOME%\bin;%PATH%
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k ANT_OPT_MIN') do set ANT_OPT_MIN=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k ANT_OPT_MAX') do set ANT_OPT_MAX=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k ANT_ADDITIONAL_OPT') do set ANT_ADDITIONAL_OPT=%%I
set CALC_ANT_OPT_MIN=
set CALC_ANT_OPT_MAX=
if "%ANT_OPT_MIN%" EQU "0" goto SKIP_ANT_OPT_MIN
set CALC_ANT_OPT_MIN=-Xms%ANT_OPT_MIN%M
:SKIP_ANT_OPT_MIN
if "%ANT_OPT_MAX%" EQU "0" goto SKIP_ANT_OPT_MAX
set CALC_ANT_OPT_MAX=-Xmx%ANT_OPT_MAX%M
:SKIP_ANT_OPT_MAX
set ANT_OPTS=%CALC_ANT_OPT_MIN% %CALC_ANT_OPT_MAX% %ANT_ADDITIONAL_OPT%
:SETUPSPLVARS
REM ---------------------------------------------------
REM Set environment variables
REM ---------------------------------------------------
echo %PATH% | findstr /I "%SPLEBASE%\bin" > nul
if ERRORLEVEL 1 set PATH=%SPLEBASE%\bin;%PATH%
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k FW_VERSION_NUM') do set FW_VERSION_NUM=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k SPLWAS') do set SPLWAS=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k CMPDB') do set CMPDB=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k SPLSYSTEMLOGS') do set SPLSYSTEMLOGS=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k SPLADMIN') do set SPLADMIN=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k SPLADMINGROUP') do set SPLADMINGROUP=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k WEB_SERVER_HOME') do set WL_HOME=%%I
set SPLBUILD=%SPLEBASE%\cobol\build
set SPLSOURCE=%SPLEBASE%\cobol\source
set SPLRUN=%SPLEBASE%\runtime
set SPLSYSTEMLOGS=%SPLEBASE%\logs\system
echo %PATH% | findstr /I "%SPLRUN%" > nul
if ERRORLEVEL 1 set PATH=%SPLRUN%;%PATH%
REM
REM Setup which compiler is to be used. Only supported option is microfocus
set SPLCOMP=microfocus
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k WEB_ISEXPANDED') do set WEB_ISEXPANDED=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k SPLApp') do set SPLApp=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k appViewer') do set appViewer=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k XAIApp') do set XAIApp=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k help') do set help=%%I
REM Setup display bill ini file - DOC1
set ONLINEBILLINI=%SPLEBASE%\etc\billdirfile.ini
set ONLINEDOCINI=%SPLEBASE%\etc\doc1dirfile.ini
:SETUPWEBAPPSERVER
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k JAVA_HOME') do set JAVA_HOME=%%I
if not exist %JAVA_HOME%\bin\java.exe echo ERROR - %JAVA_HOME%\bin\java.exe file does not exists. Exiting.&&goto EXITWITHERROR
echo %PATH% | findstr /I "%JAVA_HOME%\bin" > nul
if ERRORLEVEL 1 set PATH=%JAVA_HOME%\bin;%PATH%
if /I "%SPLWAS%" EQU "WLS" goto AFTERSETUPWEBAPPSERVER
echo ERROR - Only Weblogic is supported on Windows for OUAF. Exiting.&&goto EXITWITHERROR
:AFTERSETUPWEBAPPSERVER
:SETUPDB
goto SETUP%CMPDB%
echo ERROR - Cannot find DB setup routine. Exiting.&&goto EXITWITHERROR
:SETUPMSSQL
goto AFTERSETUPDB
:SETUPORACLE
REM We will gather the basic Database Home
for /f "delims=`" %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k ORACLE_CLIENT_HOME') do set ORACLE_HOME=%%~sI
if not defined ORACLE_HOME echo ERROR - environment variable ORACLE_HOME should be set prior to OUAF operation. Exiting.&&goto EXITWITHERROR
if not exist %ORACLE_HOME% echo ERROR - ORACLE_HOME %ORACLE_HOME% directory does not exist. Exiting.&&goto EXITWITHERROR
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k ORACLE_SID') do set ORACLE_SID=%%I
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k NLS_LANG') do set NLS_LANG=%%I
for /f %%I in ('call perl -e"$a=uc \"%NLS_LANG%\";print $a;"') do set NLS_LANG=%%I
set NLS_DATE_FORMAT=YYYY-MM-DD
set NLS_SORT=BINARY
goto AFTERSETUPDB
:AFTERSETUPDB
:SETUPCOBOL
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k RJVM') do set RJVM=%%I
if /I "%RJVM%" EQU "false" goto AFTERSETUPCOBOL
for /f %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k COBMODE') do set COBMODE=%%I
REM Set needed variables for COBOL Installations:
for /f "delims=`" %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k CHILD_JVM_JAVA_HOME') do set CHILD_JVM_JAVA_HOME=%%~sI
for /f "delims=`" %%I in ('call perl %SPLEBASE%\bin\getconfvalue.plx -k COBDIR') do set COBDIR=%%~sI
set SPLCOBCPY=%SPLSOURCE%\cm;%SPLEBASE%\services;%SPLSOURCE%
:SETUPMICROFOCUSNETEXPRESS
if not exist "%COBDIR%"\bin\cblrtss.dll goto SETUPMICROFOCUSAPPSERVER
echo %PATH% | findstr /I %COBDIR%\bin > nul
if ERRORLEVEL 1 set PATH=%COBDIR%\bin;%SPLRUN%;%PATH%
goto AFTERSETUPCOBOL
:SETUPMICROFOCUSAPPSERVER
if not exist %COBDIR%\cblrtss.dll echo Unable to find %COBDIR%\bin\cblrtss.dll nor %COBDIR%\cblrtss.dll. Please check your COBOL installation. Exiting.&&goto EXITWITHERROR
echo %PATH% | findstr /I %COBDIR% > nul
if ERRORLEVEL 1 set PATH=%COBDIR%;%SPLRUN%;%PATH%
goto AFTERSETUPCOBOL
:AFTERSETUPCOBOL
:CHECKENNVARS
REM # Check environment setup and readability of directories.
call %SPLEBASE%\bin\splstdinclude.cmd SPLcheckenvvars
if ERRORLEVEL 1 echo Error detected while calling splstdinclude.cmd.&&goto EXITWITHERROR
if /I "%SPLQUITE%" EQU "Y" goto AFTERQUITE
echo Version ................ (OUAFVERSION) : %FW_VERSION_NUM%
echo Database Type ............... (OUAFDB) : %CMPDB%
if /I "%CMPDB%" EQU "oracle" echo ORACLE_SID ............. (ORACLE_SID) : %ORACLE_SID%
if /I "%CMPDB%" EQU "oracle" echo NLS_LANG ................. (NLS_LANG) : %NLS_LANG%
echo Environment Name ....... (SPLENVIRON) : %SPLENVIRON%
echo Environment Code Directory (SPLEBASE) : %SPLEBASE%
echo App Output Dir - Logs ... (SPLOUTPUT) : %SPLOUTPUT%
echo Build Directory .......... (SPLBUILD) : %SPLBUILD%
echo Runtime Directory .......... (SPLRUN) : %SPLRUN%
echo Cobol Copy Path ......... (SPLCOBCPY) : %SPLCOBCPY%
:AFTERQUITE
if /I "%VERBOSE%" NEQ "Y" goto AFTERVERBOSE
echo Running on Operating SYSTEM (OS) : %OS%
echo Running on command interpreter (COMSPEC) : %COMSPEC%
echo Java Version
java -version
echo Perl Version
perl -V
:AFTERVERBOSE
cd /d %SPLEBASE%
if not defined CMENV goto AFTERCMENV
if exist %CMENV% call %CMENV%
:AFTERCMENV
if exist %SPLEBASE%\scripts\cm\cmenv.cmd call %SPLEBASE%\scripts\cm\cmenv.cmd
if /I "%SPLCOMMAND%" NEQ "" call %SPLCOMMAND%
goto ENDOFBAT
:USAGE
echo USAGE:
echo USAGE: %SCRIPTNAME% is the install program for Oracle application installations
echo USAGE:
echo USAGE: %SCRIPTNAME% -e environment [-c command] [-h]
echo USAGE: -e environment
echo USAGE: environment name in first field of cistab file
echo USAGE: which also has an entry in ENVIRON.INI
echo USAGE: -c command
echo USAGE: command to run at end of script
echo USAGE: -h
echo USAGE: help
echo USAGE:
goto EXITWITHERROR
:EXITWITHERROR
exit /B 1
goto ENDOFBAT
:ENDOFBAT
splstdinclude.cmd
的内容REM #
REM #% DocInfo: LEAVE THE BELOW TWO LINES IN THE RESULTANTSHELL SCRIPT
REM #% DocInfo: see the file docinfo.txt for instructions on how
REM #% DocInfo: to use this file format for self documenting scripts.
REM #
REM #% PROGRAM: splstdinclude.cmd
REM #% PURPOSE: Common functions used in most SPL scripts
REM #% DESCRIPTION: Common functions used in most SPL scripts
REM #% USAGE: call splstdinclude.cmd arg where arg1 is the function name
REM #% USAGE: additional args can be passed to the function using
REM #% USAGE: arg1, arg2, ... , arg5
REM #% DIST: release
REM #% MODHISTORY: 000101:DC:Created
REM #% MODHISTORY: 00
REM #
REM #
REM #---------------------------------------------------------------------------
REM #
:START
if /I "%1" EQU "" echo Function name not provided.&&goto EXITWITHERROR
set FUNCTIONNAME=%1
for /f "delims=~" %%I in ('echo %2') do set PARM1=%%~I
for /f "delims=~" %%I in ('echo %3') do set PARM2=%%~I
for /f "delims=~" %%I in ('echo %4') do set PARM3=%%~I
for /f "delims=~" %%I in ('echo %5') do set PARM4=%%~I
for /f "delims=~" %%I in ('echo %6') do set PARM5=%%~I
goto %FUNCTIONNAME%
REM #---------------------------------------------------------------------------
REM # start of this function
REM #---------------------------------------------------------------------------
:SPLCHECKENVVARS
REM # The Following Variables are required to be set before splenviron.sh is even started.
if not defined SPLOUTPUT echo Environment variable SPLOUTPUT is not defined.&&goto EXITWITHERROR
if not exist %SPLOUTPUT% echo Unable to find directory %SPLOUTPUT%.&&goto EXITWITHERROR
if not defined JAVA_HOME echo Environment variable JAVA_HOME is not defined.&&goto EXITWITHERROR
if not defined SPLENVIRON echo Environment variable SPLENVIRON is not defined.&&goto EXITWITHERROR
if not defined SPLEBASE echo Environment variable SPLEBASE is not defined.&&goto EXITWITHERROR
if not exist %SPLEBASE%\bin echo Unable to find directory %SPLEBASE%\bin.&&goto EXITWITHERROR
for /f %%I in ('call perl -e"$a=lc "%CMPDB%";print $a;"') do set CMPDB=%%I
if not defined SPLCOMPLOG goto AFTERSPLCHECKENVVARS
:AFTERSPLCHECKENVVARS
goto ENDOFBAT
REM #---------------------------------------------------------------------------
REM # end of this function
REM #---------------------------------------------------------------------------
REM #---------------------------------------------------------------------------
REM # start of this function
REM #---------------------------------------------------------------------------
:LOG
REM # The Following Variables are required to be set before splenviron.sh is even started.
if not defined SPLCOMPLOG echo Environment variable SPLCOMPLOG is not defined.&&goto EXITWITHERROR
if not defined PARM1 set PARM1=
if /I "%PARM2%" EQU "-q" call perl -e"use SPL::splLog;my $log=SPL::splLog->new($ENV{'SPLCOMPLOG'});$log->info('-q', '%PARM1%');"
if /I "%PARM2%" NEQ "-q" call perl -e"use SPL::splLog;my $log=SPL::splLog->new($ENV{'SPLCOMPLOG'});$log->info('%PARM1%');"
:AFTERLOG
goto ENDOFBAT
REM #---------------------------------------------------------------------------
REM # end of this function
REM #---------------------------------------------------------------------------
:EXITWITHERROR
exit /B 1
:ENDOFBAT
似乎程序在将错误级别设置为 1 后退出。有人可以帮我解决这个问题吗?
好的,潜在原因:splstdinclude.cmd
可能根本没有改变错误级别。 splenviron.cmd
在调用 splstdinclude.cmd
之前做的最后一件事是如果 findstr 设置了错误级别则调整路径。
我猜你 运行 的命令提示路径中有 COBDIR,但双击 bat 文件却没有。
您可以通过在 call %SPLEBASE%\bin\splstdinclude.cmd SPLcheckenvvars
命令的任一侧添加 echo %errorlevel%
来检查这一点。
原因是你的批次延期了!
来自Difference .bat vs .cmd
.cmd enables built-in commands to change Errorlevel to 0 on success.
当你直接调用你的 .cmd 时这有效,所以错误级别将在 set CMPDB=%%I
命令后重置为 0。
但是,当您从 .bat 文件调用它时,它不再重置,即使代码仍然包含在 .cmd 文件中,它也是使用 .bat 逻辑执行的。
所以解决方案应该是将 .bat 也重命名为 .cmd