Hello,

Depending on your liking you should look into using "dialog" boxes or a program like "pdmenu".

Michael



Shawn wrote:
I've been trying to create a script file to automate some tasks, and have come across some points that could use some outside input....

The script uses a menu interface. Basically, something like "Select what task to do:", list the tasks, then the user hits a key (or types a value followed by enter).

I found reference to the "read" command to get a value from the user. But it's not quite the best fit... It shows a flashing cursor, and control characters if the user happens to hit a cursor key. Is there a better suited command/tool for this? Ideally I'd like to label the tasks/options with letters, and then have the user just tap that letter - no enter key needed.

Next, I want to list the sub-directories of a given directory as menu options in one case. I've worked it out, but something is nagging me that there has got to be a better way..... Basically I build an array with the contents of the directory, then when I'm building the menu list, I check each item to see if it's a directory.

So, to populate the array I'm doing this:

cd $SRCDIR
dirarray=( ls * )

Then, when I'm creating the menu list with a loop like so:

[EMAIL PROTECTED]

for ((i=0; i < count; i++))
do
        if [ -d "${SRCDIR}/${dirarray[$i]}" ]; then
                echo "$i : ${dirarray[$i]}"
        fi
done

Isn't there a better way to initially populate the array with the directories only? I didn't see such an option for ls on it's man page...

And finally, I would like to pause the script when it completes a task. Something like "Hit any key to continue". So far the only option I can see is to call the read command, and just ignore it's input. Is there a better way to do this?

Thanks for any tips.

Shawn

_______________________________________________
clug-talk mailing list
[email protected]
http://clug.ca/mailman/listinfo/clug-talk_clug.ca
Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
**Please remove these lines when replying

_______________________________________________
clug-talk mailing list
[email protected]
http://clug.ca/mailman/listinfo/clug-talk_clug.ca
Mailing List Guidelines (http://clug.ca/ml_guidelines.php)
**Please remove these lines when replying

Reply via email to