BatTu-
10-03-2002, 04:12 PM
i am writing this "age" script for my unix class, i'm stuck on these following codes, can you please kindly help me.
here is what i have to code:
Write a portable KORN shell script (program) named "age" which accepts as input a person's birthday in the form yyyymmdd and prints out the following:
The persons age, in years and full months
The day of the week in which the person was born
Their zodiac sign (cancer, leo, libra, etc.)
Their fortune (use the Unix fortune cookie game program for this)
Your program should accept the birth date from the command-line. However, if the birth date was
not entered on the command-line as an argument, then the script should prompt the user to enter it.
Once you have obtained the birthdate information, you should check (verify) to make sure the user entered exactly 8 digits (numbers) as a birth date, and that the date entered is a legal date, e.g. 19870229 is not a legal date. Look on calendar. There is no 29th of February in 1987.
Your script should be able to accept any year from year 0001 to the present.
Future dates should not be accepted.
If the user did not enter exactly 8 characters, you should generate the following message:
You entered X characters, please enter your birthdate in the form YYYYMMDD.
(X is the actual number of characters the user entered)
If the user entered 8 characters but they were not all numeric, generate the following message:
Your entry contains non numeric characters, please enter your birthdate in the form YYYYMMDD.
If the date entered is non-existent, generate the following message:
You entered yyyymmdd, which is an invalid date, please enter your birthdate in the form YYYYMMDD.
(yyyymmdd is the actual date the user entered)
If the user entered a future date, generate the following message:
You entered yyyymmdd, which is a future date, please enter your birthdate in the form YYYYMMDD.
(yyyymmdd is the actual date the user entered)
the area in bold is where i'm having trouble with. Plz help, thank you in advance
here is what i have to code:
Write a portable KORN shell script (program) named "age" which accepts as input a person's birthday in the form yyyymmdd and prints out the following:
The persons age, in years and full months
The day of the week in which the person was born
Their zodiac sign (cancer, leo, libra, etc.)
Their fortune (use the Unix fortune cookie game program for this)
Your program should accept the birth date from the command-line. However, if the birth date was
not entered on the command-line as an argument, then the script should prompt the user to enter it.
Once you have obtained the birthdate information, you should check (verify) to make sure the user entered exactly 8 digits (numbers) as a birth date, and that the date entered is a legal date, e.g. 19870229 is not a legal date. Look on calendar. There is no 29th of February in 1987.
Your script should be able to accept any year from year 0001 to the present.
Future dates should not be accepted.
If the user did not enter exactly 8 characters, you should generate the following message:
You entered X characters, please enter your birthdate in the form YYYYMMDD.
(X is the actual number of characters the user entered)
If the user entered 8 characters but they were not all numeric, generate the following message:
Your entry contains non numeric characters, please enter your birthdate in the form YYYYMMDD.
If the date entered is non-existent, generate the following message:
You entered yyyymmdd, which is an invalid date, please enter your birthdate in the form YYYYMMDD.
(yyyymmdd is the actual date the user entered)
If the user entered a future date, generate the following message:
You entered yyyymmdd, which is a future date, please enter your birthdate in the form YYYYMMDD.
(yyyymmdd is the actual date the user entered)
the area in bold is where i'm having trouble with. Plz help, thank you in advance