Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Watching LXTerminal for outputs

by simonshout (Initiate)
on Feb 03, 2013 at 22:00 UTC ( [id://1016869]=perlquestion: print w/replies, xml ) Need Help??

simonshout has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

I have just started teaching myself Perl a few weeks ago for a school project so please excuse me if I do not know the technical terms for some things.

My script uses mpg321 to play an mp3 file and I want to wrap some logic in an if statement that checks to see if the song is done playing.

I am trying to "watch" the LXTerminal because when mpg321 is done playing a song it will output to the terminal:

0:00 Decoding of song.mp3 finished.

So I was wondering if there was any way for me to have my script somehow watch the terminal and wait for the line above to be output.

Even if there is any way for me to know if a song has been done playing, any help is greatly appreciated. I just need a push in the right direction

Thank you all for your wisdom!

Replies are listed 'Best First'.
Re: Watching LXTerminal for outputs (secrets)
by Anonymous Monk on Feb 04, 2013 at 01:02 UTC
      Thank you but I have read most of the documentation on this already. My script is within an infinite while loop and I cannot have mpg321 stalling the script. So I have a "system("mpg321 song.mp3 &"); line that lets it play in the background without stopping the script. I know that backticks will return a value but in my case I have to wait for the song to be finished playing so I am unsure how to pull these values from the terminal.

        Thank you but I have read most of the documentation on this already.

        What? Why not use the modules? Or view their source to see what they do?

        My script is within an infinite while loop and I cannot have mpg321 stalling the script.

        POE is all about infinite loops, use POE::Component::Player::Mpg123, it won't stall

        So I have a "system("mpg321 song.mp3 &")

        That probably won't work, you should use IPC::Open3,like Audio::Play::MPG123 does ( [jargon://UTSL), see also perlipc

Re: Watching LXTerminal for outputs
by choroba (Cardinal) on Feb 04, 2013 at 07:54 UTC
    Crossposted at StackOverflow. It is considered polite to inform about crossposting so people not attending both sites do not waste their efforts on something already solved at the other corner of the internets.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1016869]
Approved by rovf
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-03-19 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found