Document 12327255

COP4342 - Fall 2013
Assignment 5
Plotting a Field from a Simple Database
Objectives: Learn how to use the cut, head, tail, sed, and gnuplot Unix utilities and more extensive use of
the features of the awk utility.
Instructions: Your assignment is write to a shell script called that plots a field from a simple text database. It accepts as arguments a database_name and a field_name. You should check if the database_name
represents a valid database and if the field_name is one of the names of the fields defined in the schema for
the specified database. If not, then you should print an error message and exit. You should extract the values of the specified field, sort the values in ascending order, store each unique value along with the number
of times it appears in list, and plot the values. Use the /home/faculty/whalley/cop4342exec/plot.p file as
input to gnuplot to plot the values of the field. However, you will have to substitute the appropriate values
for LOWX (smallest field value), HIGHX (largest field value), HIGHY (greatest number of occurrences of
a single value), and FILE (the name of the file containing the list of field values and their number of occur rences). After generating the plot in, you should convert this file to pdf and display it using
acroread for the user. The user can choose to print the file from acroread if he/she selects to do so. After
the user exits from acroread, you should remove any temporary files created and exit the script.
For instance, below is an example invocation of the script.
% cop4342 exam2
Assume for this example that cop4342 is a valid database name (i.e. it is in the databases.txt file), it has a
schema called grades (i.e. defined in the databases.txt file), grades has fields called name, exam1, exam2,
and exam3 (i.e. defined in the schemas.txt file), and that a file exists called cop4342.db and it contains the
following data:
Smith 84 72 93
Jones 85 73 94
Ford 92 64 93
Miller 93 73 87
Green 72 72 72
White 92 72 86
Johnson 90 85 80
Douglas 90 60 70
Lewis 80 64 70
Brown 92 70 93
Daniels 85 80 80
Your shell script should produce a plot of the data that would appear as:
While you are allowed to invoke other shell scripts that you have written and predefined Unix utilities, you
are not allowed to invoke other executables. If you need to store information into temporary fi les, then be
sure to delete these temporary fi les before you exit your script.
Submission: Submit the shell script and any other shell scripts that you used in this assignment as
separate attachments in a single e-mail message to [email protected].edu via e-mail before the beginning of
class on 10/3/13.