u shall implement a Microshell, “MSH”. MSH shall provide the following functions: Provide a shell-like interface for launching new programs: When MSH starts running, it will print a prompt "cssc0000% " (replace cssc0000 with your username) and then wait for the user to type in a file name. Note, MSH will NOT have any shell built-in functions (such as cd, setenv, printenv, bg, fg, etc), with the exception of #5 (below). When the user enters a filename and hits the “enter” key, MSH then reads the filename entered and determines if the file is an executable file. If it isn't, MSH will print a useful error message to the user and then return to #1 above (display a new prompt and wait for user input). If it is an executable file, then MSH will create a new process and run this program in the new process. Note – you will need to determine whether the filename is a fully qualified path name or if the file needs to be searched for (fully qualified pathnames begin with a slash (i.e. "/"), use the correct variant of ‘exec’ to do this.
You shall implement a Microshell, “MSH”. MSH shall provide the following functions:
- Provide a shell-like interface for launching new programs:
When MSH starts running, it will print a prompt "cssc0000% " (replace cssc0000 with your username) and then wait for the user to type in a file name. Note, MSH will NOT have any shell built-in functions (such as cd, setenv, printenv, bg, fg, etc), with the exception of #5 (below).
- When the user enters a filename and hits the “enter” key, MSH then reads the filename entered and determines if the file is an executable file. If it isn't, MSH will print a useful error message to the user and then return to #1 above (display a new prompt and wait for user input). If it is an executable file, then MSH will create a new process and run this program in the new process.
- Note – you will need to determine whether the filename is a fully qualified path name or if the file needs to be searched for (fully qualified pathnames begin with a slash (i.e. "/"), use the correct variant of ‘exec’ to do this.
- MSH will support users creating two processes with a pipe for the two processes to use to communicate with each other. For example, the following is legal input:
"cssc0000% ls | sort"
In this example, MSH will create two processes and a pipe for them to use for communication between the two processes. In this example, the first process (ls program) would send its output to the second process (sort program) which would read from the pipe.
- Okay, there is one builtin function you need to implement (actually three, counting the pipe in the previous requirement and the launch a new program), if the user types "exit" (then hits the “enter” key), then your program shall gracefully close itself down and terminate.
NOTE - The ONLY valid input formats are the following (gracefully reject/don't accept all others):
- msh% executablefilename
- msh% executablefilename argument <- (only one argument, no more than one)
- msh% executablefilename | executablefilename
- msh% executablefilename | executablefilename | executablefilename <- (any number of pipes may be constructed on the command line)
- msh% exit
Your program will be tested by compiling it and executing it on edoras using these features and some bad input.
Your program shall be written such that it compiles and executes cleanly when using the gcc/g++ compiler on edoras. You shall create a sub-directory named "a2" in your home directory. In a2, you shall place your source files (multiple source files are required), your header file, your Makefile, and a README file (follow instructions from assignment #1 for the README file). Additionally, identify in your README file who worked on which lines of code in this project (if you used Agile/Pair
- Create ~/a2 by hand.
- Create multiple c/c++ source files, an include file, a Makefile, and a README file. Put them into ~/a2.
- The Makefile shall create an executable by the name of msh in the same directory (~/a2).
- The system call "system()" will NOT be allowed
Trending now
This is a popular solution!
Step by step
Solved in 6 steps