Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

How to call two programs simultaneously from a running program

by ccmbvipin (Initiate)
on Aug 11, 2008 at 05:12 UTC ( #703549=perlquestion: print w/ replies, xml ) Need Help??
ccmbvipin has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I want to call two programs simultaneously from a currently running program so as to decrease the run time. Presently I call the programs one after the other e.g. In program A.pl, I call programs B.pl and C.pl as `perl B.pl`; `perl C.pl`; In this case C is called only after B has finished running. I also need to call program D after ensuring that both B and C have been executed. Please help ... urgent

Comment on How to call two programs simultaneously from a running program
Re: How to call two programs simultaneously from a running program
by GrandFather (Cardinal) on Aug 11, 2008 at 05:15 UTC

    Take a look at fork.


    Perl reduces RSI - it saves typing

        fork is a somewhat cross platform. system "... &" is rather system dependent. There is no telling what the OP is using of course and there is a fair chance that using & will do the trick for the OP.


        Perl reduces RSI - it saves typing
Re: How to call two programs simultaneously from a running program
by ikegami (Pope) on Aug 11, 2008 at 06:16 UTC

    Do you care about the return value?
    Do you need to send data to the child via its STDIN?
    Do you need to collect data the child prints?
    On what systems must this run?

Re: How to call two programs simultaneously from a running program
by BrowserUk (Pope) on Aug 11, 2008 at 07:00 UTC
      Hi, thanks for useful suggestion I also need to call program D, but not untill both B and C have been executed. Please guide.

        use threads; use threads::shared; ... my $Bresults:shared; async { $Bresults = `perl B.pl`; }->detach; my $Cresults = `perl C.pl`; sleep 1 until defined $Bresults; my $Dresults = `perl D.pl $Bresults $Cresults`;

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re: How to call two programs simultaneously from a running program
by gloryhack (Deacon) on Aug 11, 2008 at 08:04 UTC
Re: How to call two programs simultaneously from a running program
by casiano (Pilgrim) on Aug 11, 2008 at 09:40 UTC
Re: How to call two programs simultaneously from a running program
by swampyankee (Parson) on Aug 11, 2008 at 20:17 UTC

    To add to the comments and advice of the greatly esteemed monks, ikegami, GrandFather, and BrowserUk, and while trying not to belabor the obvious, there may not be significant speedup if either B or C takes much more time than the other, e.g., if program B takes 20 seconds to run and program C takes 1, the savings by running B and C in parallel won't exceed 1 second. See also Amdahl's Law, which describes the speedup that can be expected by running processes in parallel.


    Information about American English usage here and here. Floating point issues? Please read this before posting. — emc

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://703549]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2014-12-27 04:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls