Question: PART#3 C programming to implement a simple shell. Warning: you should not use any system call (e.g., system (lsn) throughout this assignment (and thereafter). Taski.

 PART#3 C programming to implement a simple shell. Warning: you should

not use any "system call (e.g., system ("lsn) throughout this assignment (and

thereafter). Taski. One to Three Commands in Pipe You may use the

PART#3 C programming to implement a simple shell. Warning: you should not use any "system call (e.g., system ("lsn) throughout this assignment (and thereafter). Taski. One to Three Commands in Pipe You may use the sample code provided to handle two commands in pipe, to make a simple shell. Your shell handles one command, or two or three commands in pipe ls I wc -l" or "is l grep ".c" sot") For example, if there are two commands in pipe, the parent gets the command (for example, "ls I wc -l") o 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 "is") which will fork its child process (to do "we -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 "we -1"). 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 "is I grep sort"). Task2. A Command with File Redirection input, output, append). Continuing Task 1, your shell program should handle one command ("is outl txt") or two commands in pipe (for example, "ls I sort out2.txt") Hint. You may use dup or dup2 to redirect the file input or output for the given command ("ls") which a child process will execute (with exec) file redirection is specified for input "K filename if then for child process to do fid en (file name o RDONLY); close (STD INPUT); dup (fid) close (fid) PART#3 C programming to implement a simple shell. Warning: you should not use any "system call (e.g., system ("lsn) throughout this assignment (and thereafter). Taski. One to Three Commands in Pipe You may use the sample code provided to handle two commands in pipe, to make a simple shell. Your shell handles one command, or two or three commands in pipe ls I wc -l" or "is l grep ".c" sot") For example, if there are two commands in pipe, the parent gets the command (for example, "ls I wc -l") o 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 "is") which will fork its child process (to do "we -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 "we -1"). 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 "is I grep sort"). Task2. A Command with File Redirection input, output, append). Continuing Task 1, your shell program should handle one command ("is outl txt") or two commands in pipe (for example, "ls I sort out2.txt") Hint. You may use dup or dup2 to redirect the file input or output for the given command ("ls") which a child process will execute (with exec) file redirection is specified for input "K filename if then for child process to do fid en (file name o RDONLY); close (STD INPUT); dup (fid) close (fid)

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!