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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question

You shall implement a Microshell, “MSH”.  MSH shall provide the following functions:

  1. 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).

  1. 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.
  2. 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.
  1. 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.

  1. 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 programming state who was writing and who was providing input for each function/method).  Your source files SHALL CONTAIN sufficient comments for making the source easy to read. Points will be taken off for poorly (or non) commented source. Your main() should be a small function (it should look like a "table of contents" for your program).  Name the executable "msh".

  • 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
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 6 steps

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education