我创建了一个。将运行模型的批处理如下。在命令提示符(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 \”ExampleCPPFe 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 输入行太长了。
答案 0 :(得分: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