UMBC CSEE Computer Science & Electrical Engineering
University of Maryland Baltimore County
Baltimore Maryland 21250 USA
voice: 410-455-3500 fax: -3969
UMBC| CSEE| CSEE help

Project 1: Implementing a Simple Shell

(c) 1997, Howard E. Motteler; Modified by Gary L. Burt, 1998, 1999, 2000, 2001

Assigned: 3 April 2001
Due:8 May 2001

New New Date 10 May: Resubmit it necessary

Project Goals

The goals of this project are to learn the basics of how a "shell" or command interpreter works, how pipes are used, how sockets are used, and to gain experience programming with UNIX processes and system calls.

The Project

Shell

You are to design and implement a simple shell, "mysh". Some of the commands of this shell are to be internal and some are to external. The internal commands for project will be the command to list the directory (the UNIX "ls" command), the change directory command (cd) and the "exit" command).

The following is a prototype of what your main might look like:

while ( TRUE )					/* repeat forever           */
{
    read_command( command, parameters);	/* read input from terminal */

    if ( fork( ) != 0 )				/* fork off child process   */
    {
	  /* Parent Code */
	  waitpid( -1, &status, 0 )		/* wait for child to exit   */
    }
    else
    {
	  /* Child code */
        execve( command, parameters, 0 ); /* execute the command	    */
    }
}

Pipe and Sockets

You are to design and implement file-transfer system that use two Linux systems (such as Linux1, Linux2, and lab computer running under Linux). There will be two independent programs client-socket and server-socket. You will have to log into both systems and designed which machine is which. On the server side, you will start the program server-socket which will monitor the socket, waiting for commands.

On the client side, mysh will create a pipe and execute the program client-server. The client-server will wait until it receives a command on the pipe. Commands that it will be expected to handle are:

  1. remoteput
  2. remoteget
  3. remotels
Files of any size can be transferred, so you will have to coordinate the flow of data across the pipe using a semaphore, so that the data being sent does not overrun any buffers.

Sample of the socket code:

Client side
Server side

Specifications

Your shell should be able to parse and execute command lines of the following form

cmd
cmd > file
cmd < file
cmd < file > file
cmd | cmd
cmd ; cmd
!!
!nr

where:

Grading

Make sure you have read the general information on programming projects. Approximately 20% of your grade is for documentation, and the remainder is based on how well your project works. You should describe your design and implementation at the beginning of the project; this initial description is worth 15% of your grade. Describe any non-trivial data structures you have used, and briefly say how each relevant routine acts on those data structures. Do not simply echo the specifications given here.

Do not use the system() system call or invoke the UNIX shell to implement your shell!

You must do the project described here. Doing some other similar or dissimilar project, matter how difficult or clever, may be worth 0 points. This is not a group project; please do your own work, and be careful about sharing your code. It is OK to discuss design issues, but in your documentation, you should give credit to your sources.

You will be provided with a copy of the test plan that the TAs will use when the grade this project, so that you will know exactly how they will test this project.

You must have a makefile and a README file. You are to provide all necessary instructions on how to build and execute your programs in the README file, so that the TAs can do the best job of building and testing your system. Anything that you feel will help the TA should be included.

What to turn in

When your project is absolutely finished and you have completely and totally tested your work, you are to submit the project using the submit command given to you by the TA.

If your code is in more than one file, you will have to a makefile. For help with a makefile, see the TA.

Hints and Tips


UMBC   |   CSEE