免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 6975 | 回复: 60
打印 上一主题 下一主题

小女子哀声乞求!!! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-01-04 00:23 |只看该作者 |倒序浏览
这是小女子我近日要交的一份作业。
我觉的十分困难。

但是我知道对于各位大哥来说是小菜一碟。

但作是各位工作之余的消遣巴。
希望各位能从百忙之余给予我帮助。

拜托,拜托。


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个都是文档的形式,拜托。

论坛徽章:
1
荣誉版主
日期:2011-11-23 16:44:17
2 [报告]
发表于 2004-01-04 00:31 |只看该作者

小女子哀声乞求!!!

嗯... 自問論熱心的話,小弟尚不算太差...
不過,若談到"作業",那我就有所保留了...

若你真有誠意,請將"半成品"交出來吧。看看是否能給你一些提示?

论坛徽章:
0
3 [报告]
发表于 2004-01-04 00:48 |只看该作者

小女子哀声乞求!!!

原帖由 "網中人" 发表:
嗯... 自問論熱心的話,小弟尚不算太差...
不過,若談到"作業",那我就有所保留了...

若你真有誠意,請將"半成品"交出來吧。看看是否能給你一些提示?
作业?这里不是学校呀,我们也不是你同学!何况一听作业我就晕倒~~~ :em12:

论坛徽章:
0
4 [报告]
发表于 2004-01-04 03:41 |只看该作者

小女子哀声乞求!!!

作业还是自己做吧。
有细节问题不会处理再来问

论坛徽章:
0
5 [报告]
发表于 2004-01-04 10:56 |只看该作者

小女子哀声乞求!!!

学学awk  应该很好解决这个问题。

论坛徽章:
0
6 [报告]
发表于 2004-01-04 11:04 |只看该作者

小女子哀声乞求!!!

awk是什么啊?

论坛徽章:
0
7 [报告]
发表于 2004-01-04 13:18 |只看该作者

小女子哀声乞求!!!

[quote]原帖由 "流雪儿"]awk是什么啊?[/quote 发表:

???....
awk 是一种针对数据处理的编程语言,名字取自这三个开发人的姓的头一个字母!!!
a:Alfred Aho
weter Weinberger
k:Brian Kernighan
awk如果都不知道的话,你的作业恐怕交不了了!

论坛徽章:
0
8 [报告]
发表于 2004-01-04 13:38 |只看该作者

小女子哀声乞求!!!

啊哟,打击我。正在学嘛。
艾。。。。

论坛徽章:
0
9 [报告]
发表于 2004-01-04 15:22 |只看该作者

小女子哀声乞求!!!

原帖由 "流雪儿" 发表:
啊哟,打击我。正在学嘛。
艾。。。。
别人有义务帮助你解决问题,而没有责任帮你做作业呀!
你一上来就一大堆洋文,而且也没有自己写的东西,光让别人给做!,就算有人给你做,那么你又能学到什么呢 人家不能帮你N学期吧

论坛徽章:
0
10 [报告]
发表于 2004-01-04 15:42 |只看该作者

小女子哀声乞求!!!

原帖由 "bjgirl" 发表:
别人有义务帮助你解决问题,而没有责任帮你做作业呀!
你一上来就一大堆洋文,而且也没有自己写的东西,光让别人给做!,就算有人给你做,那么你又能学到什么呢 人家不能帮你N学期吧



我有写了一些,但是有很多问题啊。不知道找谁啊。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP