Advertisement

07.23.2004 at 06:31AM PDT, ID: 21069057
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

bash read/select jumping past user input stage - bug?

Asked by yoxi in Unix Systems Programming

Tags: , , , ,

Hello there

I'm using bash 2.05b (in mac OSX 10.3.4) and I've come across a weird behaviour that seems to get mentioned in other places on the 'net, but I've not been able to find out whether this has been addressed/cured?

Running the (still unpolished!) script below, the 'read' works fine, but then when it gets to the 'select' stage, it just jumps right to the end of the script. I tried using a 'read' statement instead of the 'select' - same behaviour.

Anyone know how to resolve this?

- yoxi
#######################################

#! /bin/bash
# this script parses 'diskutil list' to create 2 arrays:
# named available volumes (e.g. /volumes/Blah), and their disk IDs (e.g. disk0s10)
# it checks whether they're unmounted, then offers a list of
# unmounted volumes from which the user may choose to mount one
# - it only works for HDDs, not unmounted disk images etc.

getvols () {
linecount=0
while read dummy1 dummy2 voln dummy3 dummy4 diskn; do
# only keep lines which are mountable but unmounted volumes...
   if [ -n "$voln" ] && [ "$voln" != "name" ] && [ -n "$diskn" ] && [ ! -d "/Volumes/$voln" ]; then
      volnames[$linecount]=$voln
      diskid[$linecount]=$diskn
      linecount=$linecount+1
   fi
done

echo "${volnames[*]}"

# will do a bit more error checking here once this works...
mountvol=""
PS3='Enter the number of the volume you want mounted: '
select mountvol in ${volnames[*]}; do
   if [ $mountvol ]; then
      diskutil mount /dev/"${diskid[($REPLY-1}]}"
      break
   else
      echo 'try again!'
   fi
done
}

# here we go...
clear
echo 'This script will offer you a list of unmounted but available volumes'
echo 'from which you may choose to mount one, or'
echo 'type Ctrl-C to exit...'
echo ' '
diskutil list | getvols
Start Free Trial
 
Loading Advertisement...
 
[+][-]07.23.2004 at 08:12AM PDT, ID: 11622205

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.23.2004 at 08:42AM PDT, ID: 11622538

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2004 at 08:59AM PDT, ID: 11622708

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Unix Systems Programming
Tags: bash, read, input, user, select
Sign Up Now!
Solution Provided By: NVRAM
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.23.2004 at 09:10AM PDT, ID: 11622830

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.23.2004 at 09:14AM PDT, ID: 11622875

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.23.2004 at 02:36PM PDT, ID: 11625520

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32