MATLAB: Responding to DOS prompt from MATLAB command line

command linedosMATLABpromptsystem

I am working to interact with a Windows executable that requires input only after being called. I have successfully called executables from MATLAB that required input along with the call, but this is a little different.
After calling the executable, the user has to wait for a prompt to enter a file name. Once the prompt appears, and the file name is entered, the program runs and completes. I can invoke the program without a problem, and MATLAB responds with the same prompt to enter the filename as it does in the Windows command prompt, but I am unable to respond to the MATLAB prompt successfully. The program responds with an error regarding an invalid file identifier (executable was built using MATLAB).
I am able to run the program in a command prompt window (outside of MATLAB), so I know the program itself works, but need to run these in batch mode and would be nice to do so in MATLAB.
I have tried several iterations using 'dos','system','!', and 'unix' commands with similar results every time. I have also tried including the file name along with the call to invoke the executable, but get a response that the script is not a function.
Any help on this issue would be greatly appreciated.
-Ryan

Best Answer

Another approach with my example using File=input() works.
Assume the file name you entered through prompt is called MyText.txt.
Please create another text file first, the file is called input.txt, its content is a single line of text: MyText.txt
Run the following in Windows command line, no problem
TestCommandLine <input.txt
Run the following in Matlab command line, no problem
system('TestCommandLine <input.txt')
Can you try this and try the same with your executable?