0

I know that the title is so confusing and I should explain more:

First: I have a Fortran console application that someone else has developed. It has some inputs and outputs as text file. When the application runs it prompts for the name of input text file.

Second: I need to use the application in a "FOR loop". I am going to develop second application in Matlab so it is necessary that Matlab call first application. I do it by line below in the Matlab script:

!C:\ ... ADDRESS ...\app.exe

Matlab runs the console application and the command window shows this message:

Enter name of input parameter file:

The problem is that Matlab does not go to the next line in the script until a value entered in the command window.

Because I want the program to run more than once, I need the name entered automatically.

francescalus
  • 30,576
  • 16
  • 61
  • 96
MSD
  • 29
  • 6
  • You need some other utility to send additional keystrokes to your program. See https://www.mathworks.com/matlabcentral/fileexchange/40001-keyinject and https://stackoverflow.com/questions/27933270/programmatically-press-an-enter-key-after-starting-exe-file-in-matlab/27993740 – Navan Nov 13 '18 at 14:53
  • Try writing the parameters to .txt file with `dlmwrite('param.txt', param)`, and then passing them to system call `system('app.exe < param.txt');`. – hazeiio Nov 13 '18 at 14:55

1 Answers1

2

If the name of the input file doesn't change you can use

!echo input_file | C:\ ... ADDRESS ...\app.exe

Jakob L
  • 196
  • 6