Homework 6, the Mini Academic SHell

This homework is worth 10 points.

Goals

When you finish this homework you should:

Assignment

Create a mini academic shell (mash). This program should prompt the user for a command and execute it. The command is one of the following The run command will allow the user to execute a program. When the user types RUN the mash shell should prompt for the command line, and execute the command given, including user arguments.

The redirect command will allow the user to run a program with input/output redirected from a a file. When the user types REDIRECT the mash shell should prompt for the input file, the output file and the command. If the either the input or the output file is blank the mash shell should use standard input/output. Otherwise, it should read from and write to the given file.

The pipe command will allow the user to connect the output of one program to the input of another. When the user type PIPE the mash shell should prompt for the first and second commands and execute these two commands connected via a pipe.

Please call your program mash.

An example run might be as follows, comments are indicated by a line starting with # and are not part of the interaction.

# assume the prompt is mash=>
mash=> RUN
What command do you want to run? whoami
bennett
mash=> PIPE
What is the first command? ps -ef
What is the second command?  grep bennett
# note this is equivalent to ps -ef | grep bennett
bennett  30373 15946  0 Feb26 pts/25   00:00:00 bash
bennett  30412 30373  0 Feb28 pts/25   00:00:00 vim standard
bennett  31142 29950  0 Feb08 pts/6    00:00:00 xpaint
mash=> REDIRECT
What is the input file? foo.C
What is the output file? stats 
What command do you want to run? wc
# note this is equivalent to wc < foo.C > stats
mash=> EXIT

When you are finished email a compressed tar file containing your code, a Makefile and a README file to your instructor. Please do not include executable or object files in your submission.