These classnotes are depreciated. As of 2005, I no longer teach the classes. Notes will remain online for legacy purposes

UNIX01/Coding Our Own Add User Script

Classnotes | UNIX01 | RecentChanges | Preferences

In the previous class, we created a flat-file database called "ody_employees.dat" which was used to hold certain specific user information for our machine. Namely, that file held
  • UNIX user name
  • Full name of the user
  • Comma separated list of groups they were a part of
  • Their phone number
  • Their office number

The format of the lines in this file were as follows

 UNAME:FULL NAME:GROUP(S):PHONE:OFFICE

An example entry is as follows:

 dave:Dave Bowman:Sales:661-3247:236

Write a shell script that takes entries and adds a line to this flat file database. Call this shell script "empadduser". The script should take the name of the file as an option at the command line:

 $ empadduser ody_employees.dat

It should then prompt for the entries that will be added to the database:

 Enter UNIX user name:
 Enter full name:
 Enter group(s):
 Enter phone number:
 Enter office number:

After the user had entered in the above information, the script should append it in the proper format to the data file given at the command line. The script should then prompt if the user wishes to continue:

 Do you want to continue (y/n)?

If the user hits "y", then the script should loop back and ask for a new set of user information. The script will continue to run until the user presses "n".



Classnotes | UNIX01 | RecentChanges | Preferences
This page is read-only | View other revisions
Last edited July 26, 2003 12:02 pm (diff)
Search:
(C) Copyright 2003 Samuel Hart
Creative Commons License
This work is licensed under a Creative Commons License.