![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| limiting failed logins to three | csaunders | HP-UX | 1 | 10-18-2007 06:56 AM |
| Aplication user and kernel mode (data access) | Brendan Kennedy | High Level Programming | 1 | 05-27-2007 02:45 PM |
| AIX v.5.1 - system and user data backup | Sezgin | AIX | 5 | 01-08-2007 03:29 AM |
| Limiting length of user in while creating user | Satya Mishra | AIX | 2 | 04-14-2005 11:40 PM |
| Limiting access | misha | UNIX for Dummies Questions & Answers | 4 | 02-24-2001 04:25 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
limiting data inputs for the user
if my user has to enter the name of months to carry out a search how can I limit the input values to only the month names and nothing else?
so far my input criteria for the user is this: Quote:
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Code:
case MONTH in Jan|Feb|Mar|... you get the idea ...|Dec);; *) echo Invalid month name, play again? >&2 ;; esac |
|
#3
|
|||
|
|||
|
Quote:
|
|
#4
|
|||
|
|||
|
>&2 re-directs the output to file descriptor 2, which is called "Standard error", a channel used for outputting errors usually.
It's common unix practice. |
|
#5
|
|||
|
|||
|
Of course I forgot the dollar sign on $MONTH ... blush. Sorry about that.
|
|
#6
|
|||
|
|||
|
Code:
echo " " echo "Enter the month in which you wish to search (Please enter months in the form of Jan, Feb, Mar, etc...): " read MONTH case $MONTH in [Jj]an|[Ff]eb|[Mm]ar|[Aa]pr|[Mm]ay|[Jj]un|[Jj]ul|[Aa]ug|[Ss]ep|[Oo]ct|[Nn]ov|[Dd]ec);; *) echo "Invalid month name" ;; esac grep $5 "$MONTH" tempfile > tempmonth |
|
#7
|
|||
|
|||
|
Code:
while true; do
echo Enter month
read MONTH
case $MONTH in ...ok...) break;;
*) echo Invalid month name, try again >&2 ;;
esac
done
grep $5 "$MONTH" tempfile >tempmonth
|
|||
| Google The UNIX and Linux Forums |