Question: Help with UNIX on bash shell. Design and implement a C/C++ program to implement a simple shell. Warning: you should not use any c/c++ system()
Help with UNIX on bash shell.
Design and implement a C/C++ program to implement a simple shell.
Warning: you should not use any c/c++ "system()" function call throughout this assignment (and thereafter).
Two 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 (e.g., "ls") or two commands in pipe (e.g., "ls | wc -l" or "ls | grep ".c"").
For example, if there are two commands in pipe, the parent gets the command (for example, "ls | wc -l") to recognize that there are two commands piped together. Thus it will have a pipe to be shared, and then fork a child process (to do "ls") which will fork its child process (to do "wc -l") with the pipe shared (so that the output of one process doing "ls" will be input to the input of the other process doing "wc -l"). Meanwhile the parent waits till all the child processes are terminated, and then back to the loop for the next command from the user. Extending the shell for two commands in pipe, your shell should handle up to "three commands in pipe" (for example, "ls | grep ".c" | sort").
Your Program Name: a3p3shell1.c
Then you do
A Command with File Redirection (< input, > output, >> append).
Continuing Task1, your shell program should handle one command ("ls > out1.txt") or two commands in pipe (for example, "ls | sort > out2.txt").
Your Program Name: a3p3shell2.c
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
