![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| simple shell - how to get a parameter typed in a shell script | cmitulescu | Shell Programming and Scripting | 4 | 01-09-2009 08:45 PM |
| Simple Shell Script Need Help | kulbir | Shell Programming and Scripting | 2 | 02-27-2008 01:14 AM |
| Please Help On Simple Shell Script | dmosheye | Shell Programming and Scripting | 1 | 09-18-2006 06:38 PM |
| need a simple shell script | Mar1006 | Shell Programming and Scripting | 1 | 08-01-2006 10:45 AM |
| A Simple shell Script | provo | Shell Programming and Scripting | 2 | 12-04-2001 05:42 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
simple shell script problem
hi all. i have a little problem. im basically reading input from the user from the keyboard into the variable "phonenumber". I want to do a little error check to check if the user doesnt enter anything in for the value phonenumber.
i had this: read phonenumber if [ $phonenumber=" " ] then ..... else ..... fi but thatjust performs then instructions in between "then" and "else", but not "else" and "fi". any ideas? thanks all in advance for your help. |
|
||||
|
solution:recursively calling a function
hiiii djt0506,
got a easy solution for you ...you neeed to write a function "function Func_validate_phone_number" which will validate the phone number entered by the user. if the ph no is blank it will again call the same function and will ask the user to enter it again....until he enters any thing other than "enter". if you want to validate it further (for valid numbers or no characters etc) then you need to do some more validations....which again quiet easy .here is my code.... function Func_validate_phone_number { if [ -z "$ph" ] then echo "Phone Number cannot be blank....please re-enter." read ph Func_validate_phone_number "$ph" else echo "Thanks for giving your phone number.....bye" fi } echo "Enter the phone number" read ph Func_validate_phone_number "$ph" i have tested it .....it works fine ...cya |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|