Design and implement a better Command Shell
Design and Implement a simple shell for Linux on our Lab
machines. The shell should
- Parse the command line
- Create and execute a process for each command (and its arguments)
on the command line. You need to support a minimum of three commands on
the command line. A command is separated from the next by
- a "|" indicating a pipe between the two commands
- Support foreground and background processes
- Support a ">" or "<" sign indicating I/O redirection to from a
file
- support a builtin command "exit" that quits the shell.
Note that if you have three commands connected by a pipe, the first command
(write end of pipe) cannot do output redirection while the third (last)
command (read end of pipe) cannot do input redirection. The middle command
cannot redirect input or output.
Graduate students will
-
need to support multiple commands (more than three) on the
command line, where one command feeds its output to the next
in sequence. That is, you will need to support multiple pipes
on the command line.
- support the ";" sequencing operator. A semicolon between
two commands means: Do the first command, when the first command
finishes, do the second command. Thus for graduate students a
command is separated from the next by either a "|" or a
";"
The objective is to:
- Learn about an the Linux interface to
application programs. Specifically learn about fork(), exec(), wait()
dup(), and pipe().
- Learn about makefiles and software organization.
- Learn to find and read man pages
You will create a tarred, gzipped file named as2.tgz containing
- your source code files
- a readme, and
- a
Makefile to make your executable.
Your source should compile and run without
errors on our Linux lab machines. Here is a sample
makefile.
Turn in your tarred, gzipped file by emailing it as an
attachment to
cs446@cs.unr.edu
You can run an executable that implements the needed parsing at
% /cs/cs446/bin/shell
You will need to duplicate most of the functionality that you see.
Here is sample code:
You can save, compile, and execute these programs to see what they do.
Sushil Louis
Last modified: Mon Feb 9 12:38:18 PST 2004