Question: PART3 Design and implement a C/C++ program (a3part3.c [or a3part3.cppl) to implement a simple shell. Warning: you should not use any system call throughout this



PART3 Design and implement a C/C++ program (a3part3.c [or a3part3.cppl) to implement a simple shell. Warning: you should not use any "system" call throughout this assignment (and thereafter) Taskl. Three or More Commands in Pipe You may use the sample code provided to handle two commands in pipe, to make a shell. Your shell handles one command, or two or three commands in pipe, for example, Is /etc | grep "passw" sort ls /etc grep "*.c" | sort > a3out.txt ls | grep ".c" | sort | wc -1 > a3out.txt or more commands in pipe For example, if there are three commands in pipe, the parent gets the command (for example, "ls /etc | grep passwd | sort") to recognize that there are three commands piped together. Thus the parent forks a child (to do sort - the last command). The child will create a pipe to be shared, and then fork a child process (to do grep - the command in the middle of the command-pipe) which will fork its child process (to do ls - the first command) with the pipe shared (so that the output of one process doing "Is" will be the input to the process doing grep command). Meanwhile the parent waits for the child processes (doing the last command in the pipe sequence) to be terminated, and then back to the loop for the next command from the user Note. You should review APUE09 Section 9 for the detail, the example, the diagram and the discussion. Note. You will have a main and a function named runNcommands to receive the input string (for example, " Is /etc l grep passwd | sort ". The function will parse the commands to be run in pipe. Note. Do not enumerate a code segment for each case (case-by-case, that is, to write a code segment for 2 commands, a code segment for 3 commands, and for 4 commands, to handle max 4 commands) but to make your code generalized to handle any number of commands in pipe. You should have a for-loop to loop n times for n-commands in pipe to generate (fork) n-processes where each process creates a pipe to be shared with its child process Task2. Provide a Makefile file to compile your program. Task3. Program run and output with 3 test cases PART3 Design and implement a C/C++ program (a3part3.c [or a3part3.cppl) to implement a simple shell. Warning: you should not use any "system" call throughout this assignment (and thereafter) Taskl. Three or More Commands in Pipe You may use the sample code provided to handle two commands in pipe, to make a shell. Your shell handles one command, or two or three commands in pipe, for example, Is /etc | grep "passw" sort ls /etc grep "*.c" | sort > a3out.txt ls | grep ".c" | sort | wc -1 > a3out.txt or more commands in pipe For example, if there are three commands in pipe, the parent gets the command (for example, "ls /etc | grep passwd | sort") to recognize that there are three commands piped together. Thus the parent forks a child (to do sort - the last command). The child will create a pipe to be shared, and then fork a child process (to do grep - the command in the middle of the command-pipe) which will fork its child process (to do ls - the first command) with the pipe shared (so that the output of one process doing "Is" will be the input to the process doing grep command). Meanwhile the parent waits for the child processes (doing the last command in the pipe sequence) to be terminated, and then back to the loop for the next command from the user Note. You should review APUE09 Section 9 for the detail, the example, the diagram and the discussion. Note. You will have a main and a function named runNcommands to receive the input string (for example, " Is /etc l grep passwd | sort ". The function will parse the commands to be run in pipe. Note. Do not enumerate a code segment for each case (case-by-case, that is, to write a code segment for 2 commands, a code segment for 3 commands, and for 4 commands, to handle max 4 commands) but to make your code generalized to handle any number of commands in pipe. You should have a for-loop to loop n times for n-commands in pipe to generate (fork) n-processes where each process creates a pipe to be shared with its child process Task2. Provide a Makefile file to compile your program. Task3. Program run and output with 3 test cases
Step by Step Solution
There are 3 Steps involved in it
To address the requirements for implementing a simple shell that handles multiple piped commands without using the system call follow this detailed br... View full answer
Get step-by-step solutions from verified subject matter experts
