CSC 415 – Building Simple Shell Project 3 Total Points: 150 Points Description For this assignment you will implement your own Shell or Command Line Interpreter (e.g. to replace /bin/bash for simple interactions with the Linux Kernel.). Your shell will be character-oriented, and will fork off processes to execute user entered commands. Your shell should read lines of user input into a 256-byte buffer, then parse and execute the commands (be sure to clear the buffer between successive commands!) It should be possible for the user to specify the command to execute by giving an absolute path to the file containing the executable (e.g. ./hw1); or to use path expansion to locate the file containing the executable by using the environment PATH variable to construct a series of absolute paths and executing the first file found in this way (note that the execvp() command performs this processing automatically, you do not need to program this yourself!) Your code should parse the input string and separate it into a collection of sub-strings (stored in myargv) along with a count of the number of strings encountered (stored in myargc). Note that piped commands will require multiple argc/argv instances! Shell Requirements Your shell should support the following functions (Note : this does not mean your shell should implement LS but rather the ability to execute the LS program): â€¢ Must maintain myargc and myargv for commands you will fork. In some cases you may need multiple instances for pipe commands. â€¢ The commands cd and pwd must be implemented in your shell. â€¢ Execute a single command with up to four command line arguments (including command line arguments with associated flags). For example: â€“ myshell>> ls â€“l â€“ myshell>> cat myfile â€“ myshell>> ls â€“al /usr/src/linux â€¢ Execute a command in background. For example: â€“ myshell>> ls -l & â€“ myshell>> ls â€“al /usr/src/linux & 1 â€¢ Redirect the standard output of a command to a file. For example: â€“ myshell>> ls -l > outfile â€“ myshell>> ls -l >> outfile â€“ myshell>> ls â€“al /usr/src/linux > outfile2 â€“ myshell>> ls â€“al /usr/src/linux >> outfile2 â€¢ Redirect the standard input of a command to come from a file. For example: â€“ myshell>> grep disk < outfile â€“ myshell>> grep linux < outfile2 â€¢ Execute multiple commands connected by a single shell pipe. For example: â€“ myshell>> ls â€“al /usr/src/linux | grep linux â€“ myshell>> ls -la | wc -l â€¢ Execute the cd and pwd commands â€“ myshell>> cd some path â€“ myshell>> pwd **NOTE** That in most Linux distros CD and PWD are not a program like ls but rather they are shell built-ins. Built-ins are shell commands that are implemented in the shell and not some external binary. For giving your shell the cd and pwd commands, you need to implement these functions in the shell with your code, even if it is provided by your OS. This can be done with the chdir() and getcwd() functions in unistd.h Suggested implementation strategy to implement a shell with multiple command line arguments (using iterative refinement): – Implement your shell to simply initialize your shell, display a prompt, read in user input and print it back to the console. – Add functionality to your shell to parse user input setting the correct values for myargv and myargc. Once parsed, print myargv and myargc to the console. Note that myargvs need to be null terminated for the exec commands to interpret them correctly. – Add functionality to your shell to execute simple shell commands. Start with commands like ls, then commands with options like ls -la /home. 2 – Add functionality to shell to execute input and output redirection. It is required to implement >, >>, and <. – Add functionality to shell to execute commands in the background. For example commands like : ls -la & – Add functionality to your shell to execute the cd and pwd commands. Note these need to be implemented in your shell. Use the chdir() and getpwd() functions to implement these shell commands. – Add functionality to your shell to execute piped commands. These are commands that are connected by a shell pipe, |. Extra Credit To get points for EC, your shell needs to work first. Broken shells are not eligible for EC. â€¢ (15 – Points) Implement your shell so that any combination of shell commands from above can be used in a single command line. For example, ls -la | wc -l | wc -b OR ls -la | grep *.c | wc -l â€¢ (10 – Points) Implement the shell so the current working directory is shown on the prompt. For example: OLD PROMPT: myshell >> NEW PROMPT: âˆ— myshell ~/ >> âˆ— myshell ~/hw3 >> âˆ— myshell ~/hw3/build >> âˆ— myshell /etc >> âˆ— myshell /etc/apach2 >> DO NOT hard code the home path to your computer, you need to detect the home path of the computer your shell is executing on. Make sure ~/ is printed in all correct situations. â€¢ ( 30 – Points) Add the functionality to your shell to store a history of all commands executed. This includes the ability to scroll through this history as well and rerun previously entered commands. See your basic Linux shell for examples. This also requires the use of the up and down arrow keys to scroll through the list. Use of readline header files IS NOT ALLOWED 3 What to submit 1. source code in myshell.c 2. updated README.md with required fields filled out. How to submit â€¢ git add . â€¢ git commit -m â€ messageâ€ â€¢ git push 4
“Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!
Use Discount Code “Newclient”for a 15% Discount!”
The post csc 415 building simple shell project 3 appeared first on Student Homeworks.
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code “Newclient”
The post csc 415 building simple shell project 3 appeared first on Essay Writers.
csc 415 building simple shell project 3 was first posted on August 12, 2020 at 11:56 am.
©2020 "Essay Writers". Use of this feed is for personal non-commercial use only. If you are not reading this article in your feed reader, then the site is guilty of copyright infringement. Please contact me at firstname.lastname@example.org
csc 415 building simple shell project 3 was first posted on August 12, 2020 at 7:56 am.
©2020 "My Assignment Geek". Use of this feed is for personal non-commercial use only. If you are not reading this article in your feed reader, then the site is guilty of copyright infringement. Please contact me at email@example.com