The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 12-06-2005
Bhups Bhups is offline
Registered User
  
 

Join Date: Dec 2005
Posts: 23
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