CST8177 - Lab 12

Script Design and Implementation

Student Name

Student number

Lab section:




Objective

To practice problem-solving skills with several small scripts and their PDL, Data Dictionary (where necessary), and so on. Note: Print out your finished PDL, scripts , and test output to include in your Lab Book.

In-Lab Demo -- Demo the scripts from this lab, explaining the behaviour.

Creating script headers

The purpose of the script, named header, is to set up a script file with a header for you: it creates an otherwise empty script file with the comment header, writing the script header and the hash-bang line to the file, and makes the script executable. Additionally, the script can use either default header information from your configuration file or override the defaults by providing new information .

Task #1:

Create a configuration file header.conf in an etc directory in your home directory that sets the following variables, using meaningful names for these default values as they apply to you:

Task #2:

Write the PDL and then a short script to:

Note: Suppress all output from the utilities: you control the messages displayed on the screen.

Task #3:

Modify your PDL, Data Dictionary, and script as follows:

Display one item at a time from the list and prompt the user for a replacement value. Also request the date the script is due and its brief purpose. I suggest a tidy display; end your prompt with a space for improved readability.

Example:

Enter configuration (press Enter for default)

Script Interpreter [/bin/bash]:

Student name [Patrick Ouellette]:

Student number [040-001-002]:

Course name [Linux Operating System II]:

Course number [CST8177]:

Lab Section Number: [315]:

Script Directory: [~/bin]:

Due date:

Purpose:

New Script Name:

When the user has entered all the necessary information, create the file in the final script directory (check that a replacement directory is valid before trying to use it) unless the requested script name is already in use (see above).

Note that the New Script Name, the Due Date, and the Purpose must always be entered.

Display the contents of the newly-created script file and request the user's approval. If it's not approved, delete the file just created.

Task #4: Simplified Test Plan

Task #5: Optional Extras