Search code examples
linuxprocesspipehtmlmkfifo

Using fifos and links to control remote process from a webpage (Linux)


I'm using mpg123 in a linux server and I'm trying to control it through a webpage (apache), using links to send different controls.

mpg123 has the -C flag so you can send characters to it. "s" key = start/stop, "f" key = next track... and so on.

I think I can send mpg123 those keys with a fifo, changing mpg123 stdin to the fifo stdout but i don't know how to use the fifo in this case (how to make mpg123 "listen" to another stdin). What I've done is:

mkfifo myfifo
myfifo | mpg123 -C -@ musiclist.txt
And then I've created keys.txt adding some keys to the file:
echo "f" >> keys.txt
echo "s" >> keys.txt

Then:

cat keys.txt >> myfifo.fifo

This does not work. Can someone explain ow can I use fifos to pass messages to a running mpg123? I've googled it but can't find what I want.

This question seems to give me some light, but I still don't know how to make mpg123 listen to the fifo's output.

Thank you in advance,


Solution

  • mpg123 has it's own --fifo option