[phpBB Debug] PHP Notice: in file /includes/db/dbal.php on line 110: Undefined array key "cached"
[phpBB Debug] PHP Notice: in file /includes/db/dbal.php on line 111: Undefined array key "normal"
[phpBB Debug] PHP Notice: in file /includes/db/dbal.php on line 112: Undefined array key "total"
[phpBB Debug] PHP Notice: in file /includes/session.php on line 885: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 885: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 885: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3391: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3393: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3394: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3395: Cannot modify header information - headers already sent by (output started at /includes/functions.php:2922)
Cabrillo College Linux Classes • View topic - Alternative menu system

Alternative menu system

Introduction to UNIX/Linux

Alternative menu system

Postby ollie wright on Wed Dec 10, 2008 8:08 am

One of the hardest parts of my project was keeping the project from 'bombing' when someone entered a letter(s) or just hit enter when the menu called for a number. Myscript does a good job of this using the 'case select in' routine. I thought I would pass on an alternative. I used it as the basis for most of the menues in my project.

#!/bin/bash
# An alternative menu
# Ollie Wright 12/10/08
a=0
while [ "$a" -lt 9 ];
do
echo -n "enter something or 9 to quit "
read a
if [[ -z $(echo $a | grep "^[0-9]*$") ]] # I did not think of this myself!
then
echo "$a is a not a number "
a=0 # reset a to keep loop running
else
echo "$a is is a number " # this is where to put whatever action to take
fi
done
User avatar
ollie wright
 
Posts: 88
Joined: Wed Sep 03, 2008 7:28 pm

Return to CIS 90 - Fall 2008

Who is online

Users browsing this forum: No registered users and 0 guests

cron