Question

This project incorporates many skills learned throughout this course. Prepare the shell program described below using a modular approach that uses functions where appropriate.

First, identify the password file attached to this project, the one used in assignment 5, or create your own as desired. It will be used in this project. Make sure it at least has your own “logname” username of yourself in the file.

Second, create an office telephone directory file containing three columns of the last name, first name, and phone number of at least 10 individuals. Then create a shell program that accepts either one (last name) or two (last name and first name) arguments. Check to ensure that one or two arguments are on the command line. If there is only one argument, display a message informing the user that more than one entry might be returned from the phone book. Exit the program if there are less than one or more than two arguments.

Third, after checking on the arguments, display a prompt asking what phone book directory file to search. Test to ensure that the entry is a valid regular file that is not zero bytes in length. If not a regular file, exit the program with an appropriate message to the user on the screen. Then check to see that there are three columns in the file. If there are not three columns, display a message indicating that the file does not contain a configuration consistent with a phone book and exit the program with an appropriate message displayed on the screen.

Fourth, display a menu in the shell program that allows adding (A) an entry to the phone book, deleting (D) an entry from the phone book, modifying (M) an entry in the phone book, displaying (I) an entry in the phone book, displaying (P) all entries in the phone book in sorted order, or exiting (X) the program. Accept either an uppercase or lowercase letter for the menu option. For adding, deleting, or modifying an entry, add additional code that checks the “logname” of the user running the shell program and ensures that the user is a member of the class (in the /etc/passwd personally created password file). For security reasons, you may need to use the passwd file included as an attachment in the assignment or use your own. This program continues until the exit choice is entered.

Other General Requirements:

In addition to including the above-mentioned functionality, make sure you incorporate each of the following elements in order to receive full credit:

Inclusion of a trap statement at the top of the program and testing to ensure that it works.
Completely functional business logic for each of the menu options (i.e., adding, deleting, modifying, displaying).
Use of functions throughout- such as for each menu option
Use of Linux commands: sed and conditional statements (e.g, if and do or while)
Upload of both the actual shell program code and three or more screenshots illustrating the functionality of the menu options
Submit the shell program contents and at least three sample outputs and insert into a Word document entitled “Final_Project_<name>.doc”, where name is your first initial and last name. You can optionally use a PDF format as well.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#!/bin/bash
trap 'echo "Exit successfully..."' 0

# First, identify the password file attached to this project,
# the one used in assignment 5, or create your own as desired.
# It will be used in this project. Make sure it at least has your own
# “logname” username of yourself in the file.

################################################################3

# Second, create an office telephone directory file
# containing three columns of the last name, first name, and phone number
# of at least 10 individuals. Then create a shell program that accepts
# either one (last name) or two (last name and first name) arguments.
# Check to ensure that one or two arguments are on the command line.
# If there is only one argument, display a message informing the user
# that more than one entry might be returned from the phone book.
# Exit the program if there are less than one or more than two arguments.

if [ $# -lt 1 ] || [ $# -gt 2 ] ; then
echo "there are less than one or more than two arguments"
exit 1...

This is only a preview of the solution. Please use the purchase button to see the entire solution

$60.00

or free if you
register a new account!

Assisting Tutor

Related Homework Solutions

Get help from a qualified tutor
Live Chats