wpaddy 2008-9-2 16:20
求高手做一个 Bourne shell 价格面议
求高手做一个 Bourne shell 简单的小程序`` 有意者加 QQ 595496 价格面议~ 谢谢了
有 3 个问题 是简单的英文 我把题目贴出来下:
Task A (30 marks)
Write a shell script (to run on the Bourne shell) to copy all the files from the
directories named dir1 and dir2 to a new directory named dir3.
(1). In the beginning of your script you need to check that the directories dir1 and
dir2 exist under the current directory (if not, your script displays an error message
and then exits).
(2). All the three directory names are supplied as arguments, and the new directory
dir3 must not currently exist (ie, the creation of dir3 is part of the script).
(3). The script first copies all the files from dir1 into dir3, overwriting any existing
files in dir3 from dir1.
(4). The script then copies every file from dir2 to dir3 subject to these conditions: if
the file from dir2 is not already present in dir3 or if the dir2 file is newer than the
same dir3 file it will overwrite its namesake in dir3.
(5). Remove all the temporary files (if any) at the end of your script.
Hint: you probably need to research these UNIX commands: find, set, cp. You
should note that the cp command without any option does not preserve certain
attributes (such as ownership and timestamps).
Task 2
Write a shell script (to run on the Bourne shell) that runs an infinite loop to
monitor which users on a denial list have logged into the UNIX system more
than once.
(1). The denial list must be stored in a text file named user.deny which lists which
users are not allowed multiple logins, specified by one username per line.
(2). In the beginning of the script you need to check that the user.deny file exists
under the current directory, and if not, your script displays a message to say so and
then exits.
(3). Every 3 seconds, the script must display a warning message to report who have
logged in multiple times and who are on the denial list. Display the user’s full name
instead of his/her username in the warning message.
(4). It’s unnecessary for your script to handle the situation where a user logs in and
then logs off immediately (i.e. within a 5 second interval).
Your script for this task must be named mlog.sh. The following is a sample output
of the script (It is OK if the script leaves behind temporary files when it is finally
interrupted). The $ is the shell prompt.
Task 3
Dominion Consulting in Sydney needs a shell script (to run on the Bourne shell) to
maintain its employee records file, which contains the following information about
each employee: telephone number (8 digits, first digit non-zero), family name
(alphabetic characters), first name (alphabetic characters), department
number (2 digits), and job title (alphabetic characters). This script should let users
add, delete, search for, and display specific employee information.
(1). Create a text file named records containing the following records with fields
delimited by colons:
95671660:Jones:Sarah:45:sales manager
93272658:Smith:John:43:technical manager
98781987:Williams:Nick:35:computer officer
99893878:Brown:Sarah:12:electrician
95673456:Couch: David: 26:chef
95437869:Anderson:Sarah:19:CEO
(2). In the beginning of your script you need to check to see whether the required text
file (records) actually exists under the current directory (if not, your script displays
a message and then exits).(3). Your script (must be named menu.sh) 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 (formatted and sorted) on the screen.
Format: 5 columns, each left-justified, column order is family name, first
name, telephone number, department number and job title. Sorting: records
must be sorted by family name (ascending).
2. Searching for and displaying specific employee record(s) (search all fields,
ignoring case)
3. Adding new records to the records file.
4. Deleting records from the records file.
(4). Your script must produce the following menu:
Dominion Consulting Employees Info Main Menu
============================================
1 – Print All Current Records (formatted)
2 - Search for Specific Record(s)
3 - Add New Records
4 – Delete Records
Q - Quit
(5). After a user makes a selection and that the selected operation has been
completed, the menu must be displayed again so that the user can make another
selection.
(6). You must validate the employee details when adding a new record.
(7). A valid family name, first name and job title must be alphabetic characters and/or
spaces, but the first character must not be a space. The first digit of a valid phone
number (8-digit) must not be zero. A valid department number must only contain 2
digits.
You may need to investigate some of these UNIX commands: awk, sort, cut,
paste, sed, grep. You may also need to investigate some other UNIX commands.
Here is a sample output of your script. The $ is the shell prompt. The items in italics
are not part of the sample output. They are hints indicating how your script should
behave.