![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| to know about press button command | doctor001 | UNIX for Dummies Questions & Answers | 1 | 04-02-2008 12:46 PM |
| how to find empty folders without using -empty | lasse | UNIX for Dummies Questions & Answers | 7 | 01-16-2008 11:30 PM |
| TheOnlin Backup.com Offers Customers Free Trial - The Open Press (press release) | iBot | UNIX and Linux RSS News | 0 | 07-29-2007 09:30 PM |
| Print to Any Windows Printer from DOS, Unix, Linux, legacy ... - Press World (press r | iBot | UNIX and Linux RSS News | 0 | 07-02-2007 04:50 AM |
| Trying to capture empty variable. | radhika | UNIX for Dummies Questions & Answers | 6 | 07-26-2005 11:50 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Capture an empty key press...
I am trying to test input from the user, if they press enter with out an Y or N. I have the characheter thing sorted but when it comes to a blank or empty key press I am having trouble.
if [ ${continue} = '' ]; then clear echo "Sorry, that is an invalid choice!" exit fi I am using a KSH script in Solaris. Thanks in advance. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
use a loop such as this
until [ $INPUT = Y ] do do some stuff here done to check to see that your variable is set properly based upon what the user typed in. The loop will continue to be executed until condition is TRUE. This is useful when the expected input is a Yes/No queston or of similar type. Or check to see that the variable you use to capture standard input is actually set. You can do this by checking or an empty string. Your code was close but you were either using single quotes or were missing an end double quote. echo " Enter Some Input Data: \c" read INPUT if [ ${INPUT} = ''" ]; then clear echo "Sorry, that is an invalid choice!" exit fi Last edited by google; 11-06-2003 at 06:44 PM. |
|
#3
|
||||
|
||||
|
You need to quote the input variable or use double square brackets...
if [ "$continue" = "" ] OR if [[ ${continue} = '' ]] |
|
#4
|
|||
|
|||
|
Sorted, thanks very much google.
|
|||
| Google The UNIX and Linux Forums |