Reference no: EM133423612
Question: Write C program minishell (ms$) that goes into an infinite loop waiting for user's commands. Once a command is entered, the program should assemble and execute each command using fork(), exec() and other system calls as required with the following rules and conditions.
Rule 1: The argc of any individual command or program should be >=1 and < =6
ms$ ls -1 ~/chapter2 -S -n //valid
ms$ cat new.txt //valid
Rule 2: The argc of induvial commands or programs that are used along with the special characters listed below should be >=1 and <=6
Ex: ms$ ls -1 ~/chapter2 -S -n | wc -w //the first command has argc=5 and the second command has argc=2 which are used along with the special | character
Special Characters : The program should handle the following special characters (In accordance to Rule 2 and the additional rules listed below)
| Piping (up to 5 piping operations should be supported)
Ex ms$ cat ex1.c|grep std|wc| wc -w
// Every command/program can have argc >=1 and <=6 as per Rule 2
>, <, >> Redirection
Ex: ms$ ls -1 >>dislist.txt
&& Conditional Execution // upto 5 conditional execution operators should be supported and could possibly be a combination of && and ||
Ex : ms$ ex1 && ex2 && ex3 && ex4 && ex5 ?
ms$ c1 && c2 || c3 && c4
|| Conditional Execution // see &&
& Background Processing
ms$ ex1 & //should run ex1 in the background
; Sequential execution of commands (up to 5 commands) the argc of each command should be >=1 and <=6 as per Rule 1
Ex: ms$ cat e1.txt; cat e2.txt ; ls ; date
Should use fork() and exec() along with other pertinent system calls to run commands from minishell