![]() |
|
|
|
|
|||||||
| 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 |
| Simple Shell Script Need Help | kulbir | Shell Programming and Scripting | 2 | 02-26-2008 09:14 PM |
| Please Help On Simple Shell Script | dmosheye | Shell Programming and Scripting | 1 | 09-18-2006 03:38 PM |
| need a simple shell script | Mar1006 | Shell Programming and Scripting | 1 | 08-01-2006 07:45 AM |
| simple shell - how to get a parameter typed in a shell script | cmitulescu | Shell Programming and Scripting | 3 | 12-05-2001 11:04 AM |
| A Simple shell Script | provo | Shell Programming and Scripting | 2 | 12-04-2001 01:42 PM |
|
|
Submit Tools | LinkBack | Thread Tools | 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. |
| Forum Sponsor | ||
|
|
|
|||
|
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 |
| Thread Tools | |
| Display Modes | |
|
|
|
The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
|
| 421 service not available, remote server has closed connection ^m automate ftp autosys awk trim bash eval bash exec bash for loop close_wait command copy/move folder in unix couldn't set locale correctly curses.h cut command in unix dead.letter find grep find null character in a unix file grep multiple lines grep or grep recursive inaddr_any inappropriate ioctl for device ksh if logrotate.conf lynx javascript mailx attachment mget mtime ping port remove first character from string in k shell replace space by comma , perl script scp recursive segmentation fault(coredump) sftp script snoop unix stale nfs file handle syn_sent tar exclude test: argument expected unix unix .profile unix forum unix forums unix internals unix interview questions unix mtime unix simulator unix.com vi substitute vi+substitute+end+of+line+character while loop within while loop shell script |