[LA.pm] does system() wait?

Ofer Nave ofer at netapt.com
Mon Feb 21 19:47:45 PST 2005


The system() call, like any other function, finishes what it is doing 
before returning.  So the first system call will only return after 
realplayer is done playing song1.mp3, after which your script will then 
execute the second system() call.

You could get all three to play simultaneously by launching the process in 
the background, like this:

system( "realplayer song1.mp3 &" );
system( "realplayer song2.mp3 &" );
system( "realplayer song3.mp3 &" );

Of course, the timing will not be perfect.... and you better then go into 
a loop that waits for all three children to exit, or else your perl script 
might exit before the songs are done, which probably (but I'm not sure) 
kills the realplayer processes, since they are children processes.

If you want to execute multiple command lines simultaneously, without 
blocking, and you're willing to tolerate a long learning curve, consider 
learning POE and using POE::Component::Child.

-ofer

On Mon, 21 Feb 2005 cch2cch at netscape.net wrote:

> Hi,
> 
> I  am running activePerl 5.6 on win98se. When I run these statements:
> 
> system("...realplayer  song1.mp3");
> system("...realplayer  song2.mp3");
> system("...realplayer song3.mp3");
> 
> I expect the three songs to be played in sequence. Instead only song3 is
> played. It seems all three system() function are executed but one
> overrides the other. I  believe Perl waits for system() to  finish  
> before continuing. Is it not so in the PC environment? Thanks
> 
> 
> 
> __________________________________________________________________
> Switch to Netscape Internet Service.
> As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register
> 
> Netscape. Just the Net You Need.
> 
> New! Netscape Toolbar for Internet Explorer
> Search from anywhere on the Web and block those annoying pop-ups.
> Download now at http://channels.netscape.com/ns/search/install.jsp
> _______________________________________________
> Losangeles-pm mailing list
> Losangeles-pm at pm.org
> http://mail.pm.org/mailman/listinfo/losangeles-pm
> 



More information about the Losangeles-pm mailing list