How to use matlab to send inputs to open dos cmd window
22 次查看(过去 30 天)
显示 更早的评论
Hi,
I am developing a script that will open an executable using the "dos()" function cmd. This function opens up a sort of server process in which the function is running in the background awaiting input. What I cant figure out is how to send command via matlab to this open cmd window. The problem I run into is that once matlab opens up the cmd window and gets the server process running, I cant figure out how to send inputs via matlab to that same instance of the dos cmd window.
0 个评论
回答(3 个)
Muhammad Zayed
2020-8-14
编辑:Muhammad Zayed
2020-8-14
you can use:
!cmd &
it works for me to open the command window from Matlab
Moreover, if you want to excute something in the cmd, you can do it as follows (in my case I want to run an excutable called "Opensees" then type the file name)
!Opensees fileName.tcl &
All the above commands will open and run the excutable in an external commond prompt window. If you wish to run it inside Matalb command window, just remove the "&" symbol at the end.
I hope this helps.
P.S. I am using MATLAB R2018a - academic version
1 个评论
Maria
2022-2-16
Thank you! I was looking for this! This solution works under Window. Did you also try under Linux, how it should look like?
KSSV
2017-3-28
You can run a .batch file in dos prompt. You create the required .bat file with matlab and run it using system. Read about system and batch files.
3 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!