The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
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

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 05-15-2008
Registered User
 

Join Date: May 2008
Posts: 53
Thanks Very Much !!!
Reply With Quote
Forum Sponsor
  #9  
Old 05-15-2008
Registered User
 

Join Date: May 2008
Posts: 53
now that i have done it for months

how do i restrict user inputs for date based on the month chosen?

is it:

Code:
while true; do 
  echo " "
  echo "Enter Date of the Month (1-31): "
  read DATE
  case $DATE in [1-31]);;
  *) echo " "
  echo "Invalid date, try again" >&2;;
  esac
done

grep $4 "$DATE" *.hits >tempfile
Reply With Quote
  #10  
Old 05-15-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
The wildcard is not valid, you are looking for 1-3 or 1.

Code:
case $DATE in [1-9]|[12][0-9]|3[01]) break;;
   *) echo Invalid date, try again >&2;;
esac
Adapting it to be stricter for February etc left as an exercise ... Maybe you could put the upper limit of the range in a variable when you read the month.

(I'd hate to use a script which prompts interactively, myself.)
Reply With Quote
  #11  
Old 05-15-2008
Registered User
 

Join Date: May 2008
Posts: 53
ok i have entered this to limit it from dates 1-31

Code:
case $DATE in [1-9]|[12][0-9]|3[01]) break;;
   *) echo Invalid date, try again >&2;;
esac
but it doesnt work. it will come up to enter the date but no matter what date i enter it just asks me to enter again.
Reply With Quote
  #12  
Old 05-15-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
1-9, 10-29, and 30-31 should work, are you saying they don't?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 12:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0