You're probably running into a common problem on Windows ... which is that because the program is normally graphical, it spawns off from CMD.EXE into a background process allowing CMD.EXE to be freed up to run something else.

Solution 1: if Matlab has an option (commandline option, perhaps) to prevent this, use it. Not really a perl solution, but we're just looking for a solution you can use in perl, right?

Solution 2: Eliminate CMD.EXE. To do this, you need to use the array form of system rather than the single scalar method. So, rather than calling system("matlab -run matlab.input") ... try calling it as system(qw(matlab -run matlab.input)). This may not quite work - you may have to pass in a full pathname to matlab: system('c:/program files/matlab/matlab.exe', qw(-run matlab.input)). Note how I pulled the command out of the qw so that I could put a space in it - may be useful for you.

Of course, if you don't know ahead of time where to find matlab, you're going to have to look in $ENV{PATH} (File::Spec has a good way to get this as an array that you can look through, and I'm sure there's a module out there that can look it up for you, too).

Hope this helps


In reply to Re: System call by Tanktalus
in thread System call by newuser_perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.