- 论坛徽章:
- 0
|
这是小女子我近日要交的一份作业。
我觉的十分困难。
但是我知道对于各位大哥来说是小菜一碟。
但作是各位工作之余的消遣巴。
希望各位能从百忙之余给予我帮助。
拜托,拜托。
Dominion Consulting in Sydney needs a program to maintain its employee records file, which contains the following information about each employee: telephone number, name, department number, job title, and date of hire. This program should let users add, locate, and display specific employee information. You can meet these needs by creating several UNIX shell scripts.
You start with creating a text file named records containing the following records with fields delimited by colons:
02-95671660:Jones:Sarah:B:45:sales manager:14-12-1995
02-93272658:Simth:John:C:43:technical manager:12-10-1993
02-98781987:Williams:Nick:T:35:computer officer:10-8-1998
You main shell script (must be named menu) will present a menu of operations that a user may choose from. Among other tasks, these operations automate the process of
1. Displaying all current employee records on the screen
2. Searching for and displaying specific employee record(s)
3. Add new records to the records file
You could use a few simple UNIX command to perform task 1 (as listed above). For tasks 2 and 3, you need to write separate shell scripts (must be named search and add, respectively), and call these scripts in your main script menu.
You are strongly recommended to make a directory named kxc254ass1 under your home directory, and use kxc254ass1 as your working directory for this assignment.
Your Main Script menu
Your main script menu will produce the following menu of operations that a user may choose from
Employees Info Main Menu
========================
P - Print Current Records
S - Search for specific Record(s)
A - Add New Records
Q - Quit
Your Selection: (waiting for user input)
• After the user makes a selection and that the selected operation has been completed, the above main menu must be displayed again so that the user can make another selection. You must use a while loop together with a case conditional to implement this. Additionally your script menu must clear the user screen before the main menu is displayed. In all of the following steps, every time the main menu is displayed the user screen has to be cleared first.
• At the beginning of your menu script, you must define three variables which take the values of records, search, and add, respectively, and use these variables in all statements that refer to the files records, search, and add. For example, you may define:
record_file=records
and use $record_file in all statements that refer to the file records. One advantage of such practice is that, if at a later time you have to rename the file records, or if it becomes necessary to get your shell script to operate on a different records file, you only need to modify the above one statement instead of modifying all statements relevant to the records file.
• Following the above definitions, your menu script must check to see whether the required files (records, search, and add) actually exist under the current directory. If any of the files does not exist, your script menu must display the following message and then exit:
Required file theMissingFile does not exist.
For example, if records file does not exist, the message would be “Required file records does not exist.”
• Your script should allow the user to key in a selection (a code, P, S, A, or Q) in either uppercase or lowercase. If the user accidentally types in a code other than P, S, A, or Q, the message "Invalid code!! Press Enter to continue…" must be displayed (make sure that the cursor stays at the end of this message line instead of the beginning of the next line). After the user presses Enter, the main menu appears again so that the user can make another choice.
When the User Selects P (or p)
Here is a sample output of your script menu when the user selects P (or p) in the main menu:
(The main menu here)
Your Selection: p (user input)
02-95671660:Jones:Sarah:B:45:sales manager:14-12-1995
02-93272658:Simth:John:C:43:technical manager:12-10-1993
02-98781987:Williams:Nick:T:35:computer officer:10-8-1998
Press Enter to continue... (Waiting here for the user to press Enter. After the user presses Enter, the main menu is displayed again)
Your Script search
Your script search is activated when the user selects S (or s) in the main menu. Here is a sample output of search:
(The main menu here)
Your Selection: s (user input)
Enter keyword: Sarah (user input)
02-95671620:Jones:Sarah:M:45:admin assistant:12-12-1990
Press Enter to continue... (Waiting here for the user to press Enter. After the user presses Enter, the main menu is displayed again)
If the entered keyword does not exist in any record, search will produce the following sample output:
(The main menu here)
Your Selection: s (user input)
Enter keyword: Kate (user input)
Kate not found
Press Enter to continue... (Waiting here for the user to press Enter. After the user presses Enter, the main menu is displayed again)
• You must define a variable that takes the value of records, and use this variable in all statements that refer to the file records.
• You must allow the user to enter a keyword in both lowercase and uppercase (eg, both sarah and SARAH generate the same output).
Your Script add
Your script add is activated when the user selects A (or a) in the main menu. Here is a sample output of add:
(The main menu here)
Your Selection: a (user input)
(Clear the user screen first)
Employee Info Additions
=======================
Enter the following details of the new
employee (enter NA if not available):
Phone Number
Last Name
First Name
Middle Init
Dept #
Job Title
Date Hired
Phone Number (xx-xxxxxxxx): 02-90807986 (user input)
Last Name: Warren (user input)
First Name: Todd (user input)
Middle Init:L (user input)
Dept #: 20 (user input)
Job Title: engineer (user input)
Date Hired (dd-mm-yyyy): 01-02-1996 (user input)
Record Saved (This message is displayed only after this record has been successfully added to the records file. This message should not be displayed if this record has not been successfully added. In the latter case, the UNIX command for appending contents to an existing file will display a standard error message.)
Add another? (y)es or (n)o: y (user input)
(The above procedure - starting from “Clear the user screen first” - is then repeated)
However, if the user enters n, then add is exited and the main menu appears again, so that the user can make another selection (for example, now the user might wish to view the contents of the records file so as to make sure that the new record has actually been added into it).
If the user accidentally types in a code other than y or n, add is exited and the main menu appears.
• You must use a while loop to implement the above.
• At the beginning of your add script, you must define a variable that takes the value of records, and use this variable in all statements that refer to the file records.
• Add three new records made up by you to the records file after all your shell programs have been completed.
Submitting Your Assignment
You must submit the following four files (three shell scripts and one text file) electronically to the lecturer:
menu, search, add, records
也可以4个都是文档的形式,拜托。 |
|