LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-04-2009, 06:16 PM   #1
StephaneD
LQ Newbie
 
Registered: Nov 2004
Posts: 5

Rep: Reputation: 0
Question Accessing a process


I'm trying to use a php script to run mplayer (I'm playing audio from my server on a schedule determined by a mysql database). I can play files or playlists ok, but I want to interact with the running mplayer process as it's running. PHP will open the shell, but stops responding until the audio file is played and mplayer quits.

Right now, all I can do is send a kill command from another shell.

Is there a way to send input to a specific pid? (not specific to php)
Is there a way to send input to a specific shell? (not specific to php)

Thanks in advance!
 
Old 05-04-2009, 07:08 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
Apparently a FIFO will do:
Code:
mkfifo /tmp/mplayer-ctl
mplayer -noconsolecontrols -idle -input file=/tmp/mplayer-ctl
echo "load /path/to/mp3" > /tmp/mplayer-ctl
echo "play" > /tmp/mplayer-ctl
echo "quit" > /tmp/mplayer-ctl
 
Old 05-05-2009, 01:24 PM   #3
StephaneD
LQ Newbie
 
Registered: Nov 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Error with FIFO

mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

It's not a fifo location or permissions issue as far as I can tell. I even created the file relative to a user's home like the man page talked about.

I'm guessing I'm having an lirc issue. I installed it, but I didn't know how to configure it. I put "None" when it asked me what to configure it as, because all the options were vendors aside from /dev/input/eventx or custom and I didn't have an lirc conf file.

Thanks for your help!
 
Old 05-05-2009, 04:00 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531Reputation: 3531
No, it has nothing to do with LIRC. The first time I connected Mplayer to the fifo it didn't whine about it but the next times it did. Unless it exits immediately you should be able to send commands from another terminal window and check it's connected to the fifo on file descriptor 3 and has got the music file opened on file descriptor 4 with 'lsof -d3,4 -a -p `pgrep mplayer`'.
 
Old 05-06-2009, 12:18 AM   #5
StephaneD
LQ Newbie
 
Registered: Nov 2004
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks!

I did notice that it didn't exit. I can't test it right now, but I really appreciate your reply.
 
Old 05-08-2009, 02:02 PM   #6
StephaneD
LQ Newbie
 
Registered: Nov 2004
Posts: 5

Original Poster
Rep: Reputation: 0
FIFO command list?

I see quit as a command when I type:
mplayer -input cmdlist

But I don't see "load" so I'm wondering there's different list I should be using to control mplayer through FIFO..

It's working great, btw. Now I have to figure out why I can't nohup...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to track which process is accessing disk? mldqj Linux - Kernel 6 02-12-2009 08:20 AM
Accessing Process Control Blocks Kobbler1234 Programming 2 02-24-2008 10:08 PM
Accessing shared memory opened in a windows process in a connected linux pc gonzalesmico Programming 3 06-07-2007 03:31 PM
accessing task_struct of process shukla_chanchal Linux - General 1 11-04-2005 10:27 PM
accessing process address space linorg Programming 5 04-15-2004 02:13 PM


All times are GMT -5. The time now is 02:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration