LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   bash script to accept input ONLY until background process completes (https://www.linuxquestions.org/questions/linux-software-2/bash-script-to-accept-input-only-until-background-process-completes-158550/)

andrewstr 03-16-2004 02:59 PM

bash script to accept input ONLY until background process completes
 
I am setting up a bash script to act as a jukebox music player of sorts. The audio files are being played by mpg123. I want to allow the user various options while mpg123 is playing the music file. The options could be "quit" or "next song" for example.

I know how to use the "read" command to get user input but I don't know how to cancel the read command upon the completion of the sound file.

Any ideas?

maillion 03-16-2004 06:35 PM

Re: bash script to accept input ONLY until background process completes
 
Quote:

Originally posted by andrewstr
I am setting up a bash script to act as a jukebox music player of sorts. The audio files are being played by mpg123. I want to allow the user various options while mpg123 is playing the music file. The options could be "quit" or "next song" for example.

I know how to use the "read" command to get user input but I don't know how to cancel the read command upon the completion of the sound file.

Any ideas?

Try "select". It is made for menus and such. Look at the man pages to get the syntax.:study:

andrewstr 03-17-2004 12:02 PM

maillion,

thanks for the tip! From reading info on the select command, it appears to be perfect for my application.

Any ideas on the second part of my question? How can I kill the select menu if no option is selected by the time mpg123 is finished playing a song?


All times are GMT -5. The time now is 12:19 PM.