Homework 3, DASH (or whatever you wish).

Short Description:

Create a program that will act as a simple shell.

Goals

When you finish this homework, you should have:

Formal Description

Write a simple command line interpreter. Call it whatever you wish, but for my examples, I will use dash.

For 1/4 credit your program should

  1. prompt
  2. read the command line given
  3. execute the command, including passing arguments
  4. wait for the command to exit
  5. Return to step 1.
An example of this might be:
dash -> ls -alrt /
total 24
drwxr-xr-x.   1 root root    0 Jan 23  2024 srv
lrwxrwxrwx.   1 root root    8 Jan 23  2024 sbin -> usr/sbin
drwxr-xr-x.   1 root root    0 Jan 23  2024 mnt
drwxr-xr-x.   1 root root    0 Jan 23  2024 media
...
dash -> 
You should support the built in command quit to exit the dash shell.

For 1/4 credit you should support I/O redirection to a file.

dash -> cat < dash.cpp > newDash.cpp -n
dash -> more newDash.cpp
     1  #include <iostream>
     2  #include <sys/wait.h>
     ...
dash-> 
This should read from dash.cpp and write to newDash.cpp, but it will number the lines in the new file.

For 1/4 credit support pipes between processes

dash -> ls -a | sort -d | grep cpp
dash.cpp
two.cpp
dash-> 

For the final 1/4 credit make sure that both i/o redirection and pipes work.

dash -> grep -o '[[:alpha:]]*' < dash.cpp | sort -n | uniq > words
dash -> cat words
ParseCmd
arg
args
auto
back
...
dash -> 

Notes:

Required Files

A single c++ source code file that implements the program.

Submission

Submit the assignment to the D2L folder Homework 3 by the due date.