[PLUG] system call in php

Rob Hudson rob at euglug.net
Fri May 17 03:10:33 UTC 2002


Look at the difference between:
http://www.php.net/system
http://www.php.net/exec

I think exec doesn't wait for a response unless you pass it an array,
but you still need to redirect output to a file (/dev/null?) so PHP
knows it's not supposed to wait.  The '&' is good in that it kicks up a
child process.

-Rob

On Thu, 2002-05-16 at 19:46, Richard Steffens wrote:
> I have the following line in a php file:
> 
> system("/usr/bin/mpg123 $fileList &");
> 
> $fileList is the name of the selected option in a select box that lists
> all the .mp3 files in a particular directory.
> 
> This does what I expect it to do, mostly. The php file is on the Linux
> machine in my office. The output of that machine's sound card is
> connected to the stereo in the living room. Using a laptop in the living
> room, I connect to the php file on the machine in the office and
> successfully start music file playing with mpg123. That's the part works
> the way I expect it to.
> 
> With the "&" after the "mpg123 $fileList" I expect the php file to
> complete loading. It doesn't. I thought that the "&" was the thing to
> use to have a process start up "in the background" and let you continue
> doing other things. This does work if I run mpg123 from the command
> line. Is there something I should be doing differently with php to get
> the same effect?
> 
> Also, is there a way for php to receive information about what the pid
> is for the process it just caused to be launched? I'd like to build in a
> way to stop the music other than logging in, su'ing, running ps -ax, and
> then killing the process.
> 
> Thanks in advance.
> 
> -- 
> Regards,
> 
> Dick Steffens
> "Quando Omni Flunkus Moritati"
> http://rsteff.home.attbi.com/
> 






More information about the PLUG mailing list