Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

How do I start two programs without waiting for first one to be finished ?

by Anonymous Monk
on Oct 17, 2000 at 04:11 UTC ( #37063=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: (programs and processes)

How do I start two programs without waiting for first one to be finished ?

Originally posted as a Categorized Question.

  • Comment on How do I start two programs without waiting for first one to be finished ?

Replies are listed 'Best First'.
Re: How do I start two programs without waiting for first one to be finished ?
by tye (Sage) on Oct 17, 2000 at 10:12 UTC
    system( 1, "first" ); # Won't wait. system( "second" ); # Will wait.

    This is could be very portable though it also still appears to be mostly undocumented. ):

    Update: I posted this long ago and later learned that system(1,...) was never allowed to work except on Windows (and OS/2, for which it was originally written). Any documentation on it appears to be relegated to perlport.

         - tye
Re: How do I start two programs without waiting for first one to be finished ?
by walto (Pilgrim) on Mar 16, 2008 at 07:02 UTC
    Linux:  system "first &";
    Windows:  system "start /b first";
    Both start first in background.
Re: How do I start two programs without waiting for first one to be finished ?
by Anonymous Monk on Feb 10, 2001 at 00:59 UTC
    On Windows, I use this to launch one program and not wait, and then another with waiting.
    use Win32::Process; my $path = "C:\\mydirectory\\myprogram.exe"; Win32::Process::Create( $Process, $path, "myprogram", 0, NORMAL_PRIORITY_CLASS, "." ) or die "Can't Create - $!"; chdir "c:\\Program Files\\CoolRuler"; system "coolruler.exe";
Re: How do I start two programs without waiting for first one to be finished ?
by runrig (Abbot) on Oct 17, 2000 at 04:23 UTC
    Fork them and run in the background:
    system "( sleep 10; ls -l ) &";
    Or use fork() explicitly:
    if ( $pid = fork ) { # this is the parent } elsif ( defined $pid ) { # this is the child system "myprogram"; } else { die "can't fork: $!"; }

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2021-04-19 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?