CPE 3007 Program Development using Unix

Assignment One
Semester 1, 2003

Introduction

The purpose of this assignment is to write shell scripts to run in the Unix environment. The problem is to build a simple file manager that will allow a user to list files in a directory, to select files, and to perform actions on them. The actions are based on the file type and file permissions.

The assignment could be done as a program run in a command line environment. To make it more interesting, you should use some simple X Window applications that are designed to work in shell scripts, to build a shell script that is also a GUI application.

Supplied programs

ListSelect

ListSelect is a Java program that reads lines from standard input and displays them in a list. The input list is terminated by end-of-file. If an item in the list is selected, it's string value is printed to standard output.

ListSelect has two optional arguments

-persistent
If this flag is set, then ListSelect shows a "quit" button and will not exit. Each selection will be written to standard output. If this option is not set, then ListSelect will terminate after one selection has been made
-title title
Iif this flag is set, then ListSelect will show the string as a title

echo 'item1
item2' | java ListSelect -persistent

ButtonSelect

ButtonSelect is a Java application that shows a message and a list of buttons. Pressing one of the buttons will write the button's label to standard output. The list of buttons is read from standard input, one label per line, terminated by end-of-file.


echo 'btn1
btn2' | java ButtonSelect Press any button
 

ButtonSelect will display its command-line arguments as message text above the buttons.

Warning

Warning shows its command line arguments in a warning dialog


java Warning File not found

OnOff

OnOff displays two buttons "On" and "Off". If "On" is selected it writes "1" to standard output. If "Off" is selected it writes "0" to standard output.

Ask

Ask asks its commmand line arguments in a question dialog box. If "yes" is selected, it writes "1" to standard output and exits with an exit code of "0". If "no" is selected, it writes "0" to standard output and exits with an exit code of "1"

Cat

Cat reads lines from standard input and displays them in a dialog. If ^L is entered on a line by itself, it clears the dialog. Otherwise, each line entered is added to the dialog box

Availability

The Java class files are available as a jar file from here.

Details

Your program should consist of one or more shell scripts using the Bourne shell, common Unix utilities and any of the above Java progams. The main script can be called with zero or one argument. If called with one argument, then it should list the files in that directory. If called with zero arguments, it should list the files in the current directory.

The listing should be of all files (and directories) including "." and "..", but not any other hidden files. It should allow selection of any file in the listing and take an appropriate action based on the file type.

Using xterm

xterm normally displays a terminal window. To run a command within a terminal window, use the "-e" option


xterm -e vi
runs the vi editor in an xterm

Errors

Some attempted actions will result in errors, such as attempting to change to a directory for which you do not have permission. Errors should be reported using an error dialog.

Due date

The assignment is due on 5pm, Friday 11 April, the end of week 6.


Jan Newmarch (http://jan.newmarch.name)
jan@newmarch.name
Last modified: Tue Apr 8 15:42:53 EST 2003
Copyright ©Jan Newmarch