Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: How to run exe. file from matlab without mannually entering the input
Replies: 15   Last Post: Mar 12, 2014 12:30 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Mehdi

Posts: 14
Registered: 6/1/13
Re: How to run exe. file from matlab without mannually entering the input
Posted: Jul 11, 2013 2:29 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

TideMan <mulgor@gmail.com> wrote in message <727c894e-fbe8-4ad5-861a-5ef52405f9e9@googlegroups.com>...
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 <mulgor@gmail.com> wrote in message <9fcfced4-d118-49e0-bc91-b1b50242d969@googlegroups.com>...
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.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.