in reply to Re: execute secondary script not waiting for a result and continue with script
in thread execute secondary script not waiting for a result and continue with script

I need test2.pl & test3.pl to run at the same time, with system() it will wait for test2.pl to finish before executing test3.pl

  • Comment on Re^2: execute secondary script not waiting for a result and continue with script

Replies are listed 'Best First'.
Re^3: execute secondary script not waiting for a result and continue with script
by salva (Canon) on May 30, 2007 at 10:11 UTC
    the easy way is to use the shell to run the command on the background:
    system("test2.pl &");
    Another option is to use fork to create new processes and then exec to call the other script:
    my $pid = fork; if (defined $pid and !$pid) { exec "test2.pl"; exit(0); # just in case exec fails! }

       

      Thank you the fork works

Re^3: execute secondary script not waiting for a result and continue with script
by blazar (Canon) on May 30, 2007 at 19:59 UTC
    I need test2.pl & test3.pl to run at the same time, with system() it will wait for test2.pl to finish before executing test3.pl

    If you don't want to explicitly fork as correctly suggested to you by several monks, then a cheap way to have perl implicitly do that for you that is often is by means of piped open's.