0

我创建了一个。将运行模型的批处理如下。在命令提示符 (DOS) 我这样做: C:\Program Files\Portico\portico-1.0.2\exec> executePortico.bat name_model

示例:executePortico.bat ExampleCPPFederate

但是这个错误:

'C:\Documents' 不是内部命令或外部可运行程序或批处理文件。"C:\Program Files\Portico\portico-1.0.2\examples\cpp\cpp13\" ExampleCPPPe derate.cpp 按任意键继续。. . '"C:\Program Files\Portico\portico-1.0.2\examples\cpp\cpp13\" ExampleCPPF ederate2 '不被识别为内部命令或外部可运行程序或批处理文件。终止 - 正常

查看我的代码:

@echo off

rem ###########################
rem # implementation/version  #
rem ###########################


rem ################################
rem # check command line arguments #
rem ################################
:checkargs
if "%0" == "" goto usage
if "%1" == "" goto usage


rem #######################
rem # test for JAVA_HOME  #
rem #######################
if "%JAVA_HOME%" == "" goto nojava
goto rtihometest

:nojava
echo ERROR Your JAVA_HOME environment variable is not set!
goto usage

rem #######################
rem # test for RTI_HOME   #
rem #######################
:rtihometest
call C:\Arquivos de programas\Portico\portico-1.0.2\etc\confvarsC.bat
if not "%RTI_HOME%" == "" goto execute


############################################
### (target) execute #######################
############################################
:execute
SHIFT
set PATH=%JAVA_HOME%\jre\bin\client;%RTI_HOME%\bin;%PATH%
set RTI_FEDDIR="C:\Arquivos de programas\Portico\portico-1.0.2\examples\cpp\cpp13\"
set EXEC="C:\Arquivos de programas\Portico\portico-1.0.2\examples\cpp\cpp13\"


if "%0" == "m" goto exec1

:exec1
echo %EXEC%%1%.cpp
pause
%EXEC%%1%.cpp %2
goto finish


:usage
echo usage: executePortico.bat [model] [nome modelo]
goto err

:err
echo Terminated - Error
goto end

:finish
echo Terminated - Normal

:end

我需要做以下事情:我需要在这个软件中运行示例,这样我才能创建一个文件。我在命令提示符中运行的位置: executaPortic.bat name_model 我这样做了:

@echo off

rem ###########################
rem # implementation/version  #
rem ###########################


rem ################################
rem # check command line arguments #
rem ################################
:checkargs


if "%0"=="" goto usage
if "%1"=="" goto usage



rem #######################
rem # test for JAVA_HOME  #
rem #######################
if "%JAVA_HOME%"=="" goto nojava
goto rtihometest

:nojava
echo ERROR Your JAVA_HOME environment variable is not set!
goto usage

rem #######################
rem # test for RTI_HOME   #
rem #######################
:rtihometest
call C:\Portico\portico-1.0.2\etc\confvarsC.bat
if not "%RTI_HOME%"=="" goto execute


############################################
### (target) execute #######################
############################################
:execute
SHIFT
set PATH=%JAVA_HOME%\jre\bin\client;%RTI_HOME%\bin;%PATH%
set RTI_FEDDIR=C:\Portico\portico-1.0.2\examples\cpp\cpp13\
set EXEC=C:\Portico\portico-1.0.2\examples\cpp\cpp13\

rem ###########################
rem # if "%0"=="m" goto exec1
rem ###########################

goto exec1

:exec1
echo %EXEC%%1.exe
pause
"%EXEC%%1.exe" %2
goto finish


:usage
echo usage: executePortico.bat [model] [nome modelo]
goto err

:err
echo Terminated - Error
goto end

:finish
echo Terminated - Normal

:end

但是现在出现这个错误: C:\Portico\portico-1.0.2\exec>executePortic.bat main The input line is too long。

4

1 回答 1

0

我修复了其他几个小的语法错误,例如替换%1%为和在您的行中%1添加引号。call blah\blah\confvarsC.bat如果不知道脚本期望什么作为参数或查看示例用法,我无法解决其他一些潜在问题。我用!!!!!!评论标记了那些。

@echo off

rem ###########################
rem # implementation/version  #
rem ###########################


rem ################################
rem # check command line arguments #
rem ################################
:checkargs
if #%1==# goto usage
if #%2==# goto usage


rem #######################
rem # test for JAVA_HOME  #
rem #######################
if "%JAVA_HOME%"=="" goto nojava
goto rtihometest

:nojava
echo ERROR Your JAVA_HOME environment variable is not set!
goto usage

rem #######################
rem # test for RTI_HOME   #
rem #######################
:rtihometest
call "C:\Arquivos de programas\Portico\portico-1.0.2\etc\confvarsC.bat"
if not "%RTI_HOME%"=="" goto execute


rem ############################################
rem ### (target) execute #######################
rem ############################################
:execute

rem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
rem !!!!  SHIFT is useful if you have more than   !!!!
rem !!!!  9 arguments.  Otherwise, there's no     !!!!
rem !!!!  reason to use it.  After this, I can't  !!!!
rem !!!!  tell whether you expect %2 to be the    !!!!
rem !!!!  second script argument or the third.    !!!!
rem !!!!  -- rojo                                 !!!!
rem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

SHIFT
set PATH=%JAVA_HOME%\jre\bin\client;%RTI_HOME%\bin;%PATH%
set RTI_FEDDIR=C:\Arquivos de programas\Portico\portico-1.0.2\examples\cpp\cpp13\
set EXEC=C:\Arquivos de programas\Portico\portico-1.0.2\examples\cpp\cpp13\


if "%0"=="m" goto exec1

rem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
rem !!!!  Shouldn't there be some sort of    !!!!!
rem !!!!  "else goto" statement here?  As    !!!!!
rem !!!!  the script runs now, it will goto  !!!!!
rem !!!!  exec1 regardless of whether        !!!!!
rem !!!!  "%0"=="m"  -- rojo                 !!!!!
rem !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


:exec1
echo %EXEC%%1.cpp
pause
"%EXEC%%1.cpp" %2
goto finish


:usage
echo usage: executePortico.bat [model] [nome modelo]
goto err

:err
echo Terminated - Error
goto end

:finish
echo Terminated - Normal

:end
于 2013-02-15T13:49:15.127 回答