Operating Systems
Assignment One, 1996

Due date

This assignment is due by midnight on 25 August at the end of week 5.

Introduction

An common style of programming is to take small applications that are designed to communicate in some way, and to bolt them together to form a larger application. Under Unix, this is usually done by combining them in shell scripts, particularly using pipelines.

The majority of Unix utilities are character-based. Some that I have written are X Window-based, but can still be used in pipelines. Two are xselect, that displays a list of choices and sends selections to standard output, and xview that reads filenames of images and displays them.

This assignment is to build a "picture viewer". That is, you need to write a shell script using a mixture of character and X Window applications that will display a list of "image descriptions". When a description is selected, a corresponding image will be displayed.

The relation between image filenames and descriptions will be given in a configuration file. Various sanity checks should be performed to ensure the program you write is robust in the face of errors.

xselect

xselect is an X Window application that reads lines of text and displays them in a selectable list. When the user clicks on one of the items the text of the item is sent to standard output, newline terminated.

xview

xview is an X Window application (actually, a Java application) that reads lines from standard input. When a line is read it is interpreted as the file name of an image, and that image is diplayed. Currently, the images must be GIF images.

Configuration file

The configuration file must consist of a set of lines each containing a filename (with no embedded white space) followed by a description that can contain white space. The description will be separated from the filename by an arbitrary amount of whitespace. For example,
boy.gif             A boy on a bike
girl.gif A girl on a swing
children.gif			Two	children
You may assume that the configuration file is syntactically corrrect: each line will contain at least two "words" separated by white space.

Specification

Write a bash shell script that will run with one command line argument. The argument will be the name of a configuration file, with format as described above.

The program will display the list of descriptions using xselect. When a description is chosen, the corresponding image file will be displayed using xview.

Your script should allow the user to select images one after another. On each selection the new choice should be shown. These successive images should be shown in the same xview window.

Possible errors

Some of the possible errors that might occur in attempting to run the script include You should produce suitable error messages, and take suitable action (exit or continue). The programs xwarn and xerror take strings as command line arguments and display them in suitable dialog boxes.

Submission

Your shell script should be submitted electronically using the give command:
	give a1 filename-of-your-shell-script
This will make a copy of your shell script in a file where OS tutors can access it, but no-one else.

The give command can be run as often as you like. Each new submission overwrites any previous one (see exception later). No record is kept of the number of times you run the command.

Assignments submitted after the due date are stored under a different name to assignments submitted on time. Late penalties may be attached to assignments submitted late.

Coding standards

No separate documentation should be submitted. These assignments are small enough that internal documentation should be adequate.

Each assignment should contain at least

Any functions used should be documented. Obscure pieces of code should be described. Obvious pieces should not be described.

Consistent and readable indentation must be used. Names of variables should be meaningful.