LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-13-2019, 01:54 PM   #1
zimbot
Member
 
Registered: Nov 2005
Location: cincinnati , ohio . USA
Distribution: ubuntu , Opensuse , CentOS
Posts: 173

Rep: Reputation: 17
my case loop never ends


Friends,

My goal is to have a script where I can choose 3 different values for a var.
the var is a number , a datarate for making mp3

I have tried case
this works out
!!BUT
after the script 'finishes"
meaning
I can select a choice
that choice is a worthy var and I have made my mp3
the script does not - exit it returns to a prompt of
#?
and if I hit enter
i get the case menu selection again , and again until i do a cntrl c

here are my 2 efforts
vers1 just a case selection
vers2 a case selection nested in a do while ...that i hoped would fix it

----------:: v1 start
: 1



#!/bin/bash
## audio_defineDR_mp3.sh
PS4="Please select a data rate for your file "
select option in 128 192 256 quit
do
case $option in
128)
dr=128k
echo "128";;
192)
dr=192k
echo "192";;
256)
dr=256k
echo "256";;
quit)
break;;
esac
#done

ffmpeg -i /media/j/data/z/1.wav -codec:a libmp3lame -b:a $dr /media/j/data/z/1.mp3
echo finshed we hope ok
done




==================



v2--start





#!/bin/bash
## audio_defineDR_mp3.sh
select=0
while [ $select -eq 0 ]; do
#echo The count is $select

PS4="Please select a data rate for your file "
select option in 128 192 256 quit
do
case $option in
128)
dr=128k
let select=select+1
echo "128";;
192)
dr=192k
let select=select+1
echo "192";;
256)
dr=256k
let select=select+1
echo "256";;
quit)
break;;
esac
#done
echo $select
ffmpeg -i /media/j/data/z/1.wav -codec:a libmp3lame -b:a $dr /media/j/data/z/1.mp3
echo finshed we hope ok
done
done

-v2 end

I am on ubuntu 18.04

thanks in advance!
 
Old 08-13-2019, 02:18 PM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 11,968
Blog Entries: 9

Rep: Reputation: 3198Reputation: 3198Reputation: 3198Reputation: 3198Reputation: 3198Reputation: 3198Reputation: 3198Reputation: 3198Reputation: 3198Reputation: 3198Reputation: 3198
Because that's how select works.
See:
Code:
help select
If you want to quit after the ffmpeg command, simply add 'exit':
Code:
...
ffmpeg -i /media/j/data/z/1.wav -codec:a libmp3lame -b:a $dr /media/j/data/z/1.mp3
echo finshed we hope ok
exit
...
 
  


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
LXer: For world’s biggest troll, first patent case ends up in tatters LXer Syndicated Linux News 0 04-23-2014 06:20 AM
LXer: SCO - The party never ends LXer Syndicated Linux News 0 09-21-2009 05:11 PM
LXer: Work Never Ends! More Unix/Linux Cartoons LXer Syndicated Linux News 0 03-15-2009 04:30 PM
It never ends.. Jeebizz General 9 02-22-2009 12:09 PM
Apollon... Conecting... Never ends.. doraimom Linux - Software 0 12-17-2008 08:46 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:23 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