[PLUG] system call in php

Richard Steffens rsteff at attbi.com
Fri May 17 15:41:04 UTC 2002


Wil Cooley wrote:

> Try instead:
> 
> system("sh -c \"/usr/bin/mpg123 $fileList &\"") ;
> 
> The background '&' is a shell operation and the PHP system call might or
> might not exec a shell.

Didn't make any difference.

Rob Hudson wrote:

> 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.

exec worked the same way as system. However, while reading the info at
php.net I came across this note.

  Note: If you start a program using this function and want to leave it
  running in the background, you have to make sure that the output of
  that program is redirected to a file or some other output stream or
  else PHP will hang until the execution of the program ends. 

I included redirection in my system call and got what I was looking for. 

system("/usr/bin/mpg123 1>outputfile 2>errorfile $fileList &");

Thanks for the suggestion of where to look.

-- 
Regards,

Dick Steffens
"Quando Omni Flunkus Moritati"
http://rsteff.home.attbi.com/




More information about the PLUG mailing list