Sorry I just saw your reply. Can you please elaborate on ControlFile.ctl and what you meant by keystrokes? What the exe file asks for upon opening is the path of the text file that it reads (where it is saved). In other words, it doesn't ask for variables or parameters. I'm really desperate. Thank you again for your continued help.
TideMan <email@example.com> wrote in message <firstname.lastname@example.org>... > On Sunday, June 2, 2013 9:16:23 AM UTC+12, dpb wrote: > > On 6/1/2013 3:13 PM, Mehdi wrote: > > > > > Hello folks, I have an executable file (generated from a FORTRAN code) > > > > > that I need to run from matlab. Upon execution, it asks for the path of > > > > > the input file (C:\...Myprograms\sample.dat) and I have to enter it > > > > > manually but I want to do this programmatically, i.e., I want matlab to > > > > > get the input automatically and run the exe. I presume the function: > > > > > system (C:\...Myprograms\myexecutable.exe) is supposed to do the job but > > > > > for some reason it fails. Can anybody help me please? I'd be very grateful. > > > > > > > > If it uses standard input, you should be able to use command line > > > > redirection as part of the command string you submit... > > > > > > > > -- > > In other words, do this: > system('MyProgram.exe < ControlFile.ctl'); > The "<" tells DOS to use that file, not input from keyboard. > ControlFile.ctl must contain all the keystrokes that you would use to enter the parameters from the keyboard.