On Thursday, July 11, 2013 6:29:07 PM UTC+12, Mehdi wrote: > TideMan <email@example.com> wrote in message <firstname.lastname@example.org>... > > On Thursday, July 11, 2013 3:45:08 PM UTC+12, Mehdi wrote: > > > > 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. > > > > > > Don't top post. > > > It makes the thread hard to follow. > > > Put your reply UNDERNEATH. > > > > > > You say the program doesn't ask for variables or parameters, but for the path of the text file. Well, that IS the parameter, so your ControlFile.ctl must contain one line that looks like this: > > > c:\MyData\data.txt > > > > > > And if it then asks for the number of data and the name of the output file, your ControlFile.ctl would look like this: > > > c:\MyData\data.txt > > > 1000 > > > c:\MyData\output.txt > > > > > > That's what I mean by the keystrokes. You must put in the .ctl file all the keystrokes you would enter if you were running it from DOS. > > > I'm afraid I cannot explain it any simpler than that. > > > > Thank you. What I put in the myprogram.exe when I run it from DOS is this: > > C:/Mysoftware/for005.dat > > and it works perfectly (it doesn't ask for the number of data and the name of the output file). I followed what you said and ran the code: > > > > system('C:/Mysoftware/Myprogram.exe < C:/Mysoftware/for005.dat'); > > but it doesn't work. In the command window I get: > > Enter the input file name: > > Unable to open this file. Try again > > > > Is there anything wrong with my code? Thanks afresh.
Well, you didn't follow my instructions, did you? Read the 2nd paragraph of my last post again and follow my instructions to the letter.
BTW, this has nothing to do with Matlab. You should be able to do it in a DOS window by typing C:/Mysoftware/Myprogram.exe < ControlFile.ctl