Using the system/dos command to run an external program (RSOFT) using that program's custom DOS command
3 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am attempting to use Matlab to run in the background simulations from another program. I was hoping that the system command would work for this, but it seems to run into the following error:
'dfmod' is not recognized as an internal or external command, operable program, or batch file
One more thing to note is that I can do all of this in the normal command line running the exact commands that I use in the system commands, but do not receive an error, and further, I am able to see the simulation window open and run (which is what I expect).
This error is mitigated with a slightly different version of the code, but as I mention above, I should be able to see the command execute in the background, which I do not observe. The following code is what runs into the problem:
% Running commands in the command prompt on Windows
test_path = 'C:\RSoft\examples\diffractmod\Tutorial\tut4';
% Switching to the correct directory works perfectly
command = ['cd /d', test_path, ' &'];
[status, cmdout] = system(command, '-echo')
command = 'dfmod checkerboard3d.ind prefix=run1';
[status, cmdout] = system([command], '-echo'); % This causes the error above
% Using this instead of above yields no error, but does not seem to run the simulation
[status, cmdout] = system(['set PATH=', test_path, ' ; ', command], '-echo');
2 件のコメント
dpb
2020 年 4 月 19 日
編集済み: dpb
2020 年 4 月 19 日
The first fails because the two sequential system commands are totally unrelated -- each spawns a new process which starts with the default startup directory location -- hence, the CD has no effect on the subsequent call.
I didn't try to parse the actual command sequence the last transmorgrifies into, but the simplest and best way is to build a batch file that sets the necessary local environment and runs the application, then dispatch the batch file instead.
Alternatively, depending on command line length limits, and what the app needs for its running environment, you can embed the full pathname to the app...if it will run in the default startup location from CMD window, then it should do so when dispatched. Depends on just what it needs in DLL support, etc., and how it was coded to be able to find those.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Multicore Processor Targets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!