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

exec executes your command test2.pl and never returns to your script. You probably want system instead.
  • Comment on Re: execute secondary script not waiting for a result and continue with script
  • Download Code

Replies are listed 'Best First'.
Re^2: execute secondary script not waiting for a result and continue with script
by clinton (Priest) on May 30, 2007 at 10:06 UTC
Re^2: execute secondary script not waiting for a result and continue with script
by PugSA (Beadle) on May 30, 2007 at 10:02 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

      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

      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.