Sending data to persistent process stdin
| From: | Ville Mattila | Date: | Sat, 05 Aug 2006 13:08:23 +0000 |
| Subject: | Sending data to persistent process stdin | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-240184@lists.php.net to get a copy of this message | ||
Hello readers,
I have been thinking of making a simple web-based interface to control my media center box (running debian linux). Being a bit enthustiatic, I thought I could use some generic tools for playing media files and write the whole UI by my own.
I found mpg123 program that can be run in "remote mode" (mpg123 -R) so that playback can be controlled via stdin. Writing "LOAD <mp3 file>" to the stdin will begin output, "PAUSE" will stop it and so on.
How could I use PHP and its process functions to send something to stdin of a persistent process? I would like to run mpg123 only once, whichafter a few PHP scripts would send data and proper commands to its stdin. Maybe a kind of daemon process would be needed? Anyway, sending data to a daemon can be problematic... Maybe a kind of socket wrapper? Well - I have no experience about socket functions of PHP...
Tips and tricks are welcome, or should I just go to the local hi-tech market and by a CD player LOL :D
Thanks,
Ville