Batch file doesn't execute completely after other .exe is executed
I'm trying to create batch file which should have this commands:
cd "c:\Program files\NuSMV\2.5.2\bin\"
NuSMV -int short.smv
go
pick_state -r
print_current_state -v
simulate -r 3
show_traces -t
show_traces -v
The problem I encounter is this: after the second line is executed, NuSMV.exe runs in cmd and rest of the commands don't execute until I exit开发者_运维百科 NuSMV, but I want to run commands 3-8 in NuSMV. What do I need to change in my .bat file. Thanks.
Put commands 3-8 in a text file (eg., cmds.txt), then run NuSMV as follows:
NuSMV -int short.smv -source cmds.txt
From the manual (nusmv.pdf) p.48:
It is also possible to make NUSMV read and execute a sequence of commands from a file, through the command line option -source: system prompt> NuSMV -source cmd file
Completing Vik answer, you can create the NUSMV commands file in the same BAT file
@echo off
pushd "c:\Program files\NuSMV\2.5.2\bin\"
echo go >"%TEMP%\cmds.txt"
echo pick_state -r >>"%TEMP%\cmds.txt"
echo print_current_state -v >>"%TEMP%\cmds.txt"
echo simulate -r 3 >>"%TEMP%\cmds.txt"
echo show_traces -t >>"%TEMP%\cmds.txt"
echo show_traces -v >>"%TEMP%\cmds.txt"
NuSMV -int short.smv -source "%TEMP%\cmds.txt"
del "%TEMP%\cmds.txt"
popd
Additionally I would recommend you to not change the current directory to NuSMV directory. Either editing the PATH, or just specifying NuSMV with its full path. In both cases you should then invoke the BAT from the current directory where short.smv is located.C
@echo off
echo go >"%TEMP%\cmds.txt"
echo pick_state -r >>"%TEMP%\cmds.txt"
echo print_current_state -v >>"%TEMP%\cmds.txt"
echo simulate -r 3 >>"%TEMP%\cmds.txt"
echo show_traces -t >>"%TEMP%\cmds.txt"
echo show_traces -v >>"%TEMP%\cmds.txt"
"c:\Program files\NuSMV\2.5.2\bin\NuSMV" -int short.smv -source "%TEMP%\cmds.txt"
del "%TEMP%\cmds.txt"
精彩评论