c code輔導

CSCI212 assignment3 solution: shell interpreter implementation

 

CSCI212/MCS9212

Assignment 3 (7.5 marks)

<标题>Due 11:59pm Sunday May 17, 2015.

The aim of this assignment is to write a simple shell interpreter demonstrating you knowledge of process

control. In addition to this you will get some experience with file system API’s.

<标题>Task One (4.5 marks)

You first task is to write a simple shell interpreter, which executes commands. You shell interpreter should

display a $ prompt and wait for user input.

<标题>You shell interpreter is to be a little simplistic, all you can do is execute commands. If a command cannot be

<标题>found you should display a suitable error message. When executing a command the shell interpreter should

<标题>wait until the command terminates. To implement command execution simply use the function call fork()

<标题>and exec(). Note that there are many variations on the exec() function call. To block the shell, you

should use the wait() (or similar) function call.

<标题>At the end of this step you should be able to do this:

$ ./foobar

./foobar does not exist.

$ ls