Search for question
Question

Assignment:

Create a simple “shell” program that performs the following:

1. In a loop, prompt the user for a command and parameters. (fgets is a good tool for

this)

2. When a command is given, insert the command and the parameters into an array of

C strings. Use strtok to tokenize the string. Fork the process and have the parent

wait for the child to complete. Have the child execute the given command using

execvp execute command. Here’s POSIX documentation on exec.

3. Loop until the user enters “exit”.

4. Your program doesn’t have to do pipes(|), redirects (> or >>), or history1.

Your program will prompt the user for input that will be executed. So if I was to type:

ls -al

you would execute the command and pass -al to the command (using execvp). The

command ls with appropriate options would execute and display its output to the screen.

The program will then prompt again and wait for the next input, until exit is entered.

Read Programming Project 1 at the end of chapter 3 of our book. It’s similar to what I am

asking you to do, except, you don’t have to do pipes, redirects, and history (it is discussed

in the book though).

Submit three files (simpleShellYourNAME.c, Makefile, and README2) as your

assignment. Once you have the files on your machine, zip them and upload to

WesternOnline. README file should explain what problem your program solves and how

to compile and use it, and make, when executed, should compile everything correctly.