Question: 1. write a C program(Purpose to use below):- i) using system calls fork, wait, execvp, open, close, dup, dup2, and pipe ii) use Command Line

1. write a C program(Purpose to use below):- i) using system calls fork, wait, execvp, open, close, dup, dup2, and pipe ii) use Command Line Interpreter (CLI)

2. More details A shell is also known as command line interpreter. First, your shell must have a prompt string. You can choose any prompt you like. It may look like the following: PURDUE> ls l In the above example, PURDUE> is the prompt string, ls is a command name, and -l is an argument of the command. The command name is usually the filename of the executable.

3. Shell Language Grammar The following shows the grammar for your users to compose a valid shell command. Program should be able to parse an input line, and decide if the users input is valid or not. In the grammar below, [obj] denotes obj inside [ ] is optional; | denotes Unix pipe; * denotes 0 or >=1 occurrences.. About &: The input command line will be running as a background process. Note that a shell must wait until the program completes unless the user runs a background process (i.e., using &).

5. Programing requirement: your program and shell should support following features:- 1) Program should keep accepting new commands lines until users input exit. Your shell should have a prompt string. 2) A users command line may or may not have < at the beginning. 3) A users command line may or may not have > in the end. 4) There may be up to 9 pipes in a command line (its OK if you want to support more than 9 pipes). 5) A user may run a command line as a background process (i.e., the command line ends with &).

Here are two example command lines that are valid: PURDUE> cat < aaa | more | more | grep 2 | sort | head | wc > bbb & PURDUE> cat < aaa | more | more | grep 2 | sort | head | wc > bbb

Here are two example command lines that are not valid: PURDUE> ls | cat < tmp.txt PURDUE> ls > tmp.txt | more

Note: All System Calls must have error checking!

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!