Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^2: Run sequential processes (Matlab, SAS, etc.) from Perl

by rizzy (Sexton)
on Nov 27, 2010 at 16:57 UTC ( #874002=note: print w/ replies, xml ) Need Help??

in reply to Re: Run sequential processes (Matlab, SAS, etc.) from Perl
in thread Run sequential processes (Matlab, SAS, etc.) from Perl

Okay, I tried this at the command line, but it immediately started processing BOTH before the first had finished:

matlab mycode.m log.txt | perl

the matlab code spits out a csv file that is needed in the perl script.

The matlab code is run in the background. Maybe that's affecting this.

By the way, I also tried using semicolons as suggested, but the result was the same. I need to wait until the first process has completed before starting the second.

Comment on Re^2: Run sequential processes (Matlab, SAS, etc.) from Perl
Re^3: Run sequential processes (Matlab, SAS, etc.) from Perl
by Marshall (Prior) on Nov 28, 2010 at 23:53 UTC
    The pipe idea (prog1 | prog2 | prog3) works best when these prog's are designed to read STDIN and output to STDOUT (not directly to files). I don't think that is what you want.

    If I understand correctly, when you type in the command "matlab...", that program starts a process in the background and returns immediately to the command line while this background process is still running. If you type in a command that uses the output file that matlab creates, it doesn't work because matlab is still working on that output file. So, make a simple script file with the commands as described by others. Right after the matlab command, put in the "fg" command. That moves the most recently started background process into the foreground. Now the next command won't get executed until this now foreground process finishes.

    An alternative is to use the "wait" command. wait command. Just put "wait" after the matlab command. See the example in the link.

      You are correct on both counts. The matlab (or sas) process runs in the background and I am immediately given access to the command line.. I think fg and/or wait will do what I want. I'll give it a try. Thanks!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://874002]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2014-09-21 05:35 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (166 votes), past polls