Question: Overview In this assignment, you will implement acommand line interpreter (CLI)or, as it is more commonly known, ashell. The shell should operate in this basic

Overview

In this assignment, you will implement acommand line interpreter (CLI)or, as it is more commonly known, ashell. The shell should operate in this basic way: when you type in a command (in response to its prompt), the shell creates a child process that executes the command you entered and then prompts for more user input when it has finished.The shells you implement will be similar to, but simpler than, the one you run every day in Linux. If you don't know what shell you are running, it's probablybash. One thing you should do on your own time is learn more about your shell, by reading the man pages or other online materials(and the associated Shell Introduction file).

Program Specifications

Basic Shell: myshell

Your basic shell, calledmyshellis fundamentallyan interactive loop: it repeatedly prints a promptmyshell>(note the space after the greater-than sign), parses the input, executes the command specified on that line of input, and waits for the command to finish. This is repeated until the user typesexit. The name of your final executable should bemyshell.The shell can be invoked with either no arguments(interactive)or a single argument(batch0; anything else is an error. Here is the no-argument way:prompt>./myshellmyshell>At this point,myshellis running, and ready to accept commands. Type away!The mode above is calledinteractivemode, andallows the user to type commands directly. The shell also supports abatch mode, which instead reads input from a batch file and executes commands found in the file. Here is how you run the shell with a batch file namedbatch.txt:prompt>./myshellbatch.txtThere is a difference between batch and interactive modes: in interactive mode, a prompt is printed (myshell> ).

In batch mode, no prompt should be printedduring execution of commands.You should structure your shell such that it creates a process for each new command (the exceptionsarebuilt-in commands, discussed below). Your basic shell should be able to parse a command and run the program corresponding to the command. For example, if the user typesls -la /tmp, your shell should run the program/bin/lswith the given arguments-laand/tmp(how does the shell know to run/bin/ls? It's something called the shellpath; more on this below).Your project is to develop/write a simple shell -myshell-that has the following properties:

1.The shell must support the following internal commands:a.cd -Change the current default directory to . If the argument is not present, report the current directory. If the directory does not exist an appropriate error should be reported. This command should also change the PWD environment variable. b.clr -Clear the screen.c.dir -List the contents of directory .d.environ -List all the environment strings.e.echo -Display on the display followed by a new line (multiple spaces/tabs may be reduced to a single space).f.help -Display the user manual using the more filter. g.pause -Pause operation of the shell until 'Enter' is pressed.h.quit -Quit the shell.i.The shell environment should contain shell=/myshell where /myshell is the full path for the shell executable(not a hardwired path back to your directory, but the one from which it was executed).

2.All other command line input is interpreted as program invocation,which should be done by the shell forking and execing the programs asits own child processes. The programs should be executed with an environment that contains the entry: parent=/myshellwhere /myshellis as described in 1.i. above.

3.The shell must be able to take its command line input from a file. Thatis, if the shell is invoked witha command line argument: myshell batchfilethen batchfileis assumed to contain a set of command lines for the shell to process. When the end-of-file is reached, the shell should exit.Obviously, if the shell is invoked without a command line argument, itsolicits input from the user via a prompt on the display.

4.The shell must support I/O -redirection on either or both stdinand/or stdout. That is, the command lineprogramname arg1 arg2 < inputfile > outputfilewill execute the program programnamewith arguments arg1and arg2, the stdin FILE stream replaced by inputfileand the stdoutFILEstream replaced by outputfile. stdoutredirection should also be possible for the internal commands dir, environ, echo, & help. With output redirection, if the redirection character is >then theoutputfileis created if it does not exist and truncated if it does. If the redirection token is >> then outputfileis created if it does not exist and appended to if it does.

5.The shell must support background execution of programs. Anampersand (&) at the end of the command line indicates that the shell should return to the command line promptimmediately after launchingthat program.

6.You are to include an implementation of command line pipes. (essentially an extension of redirection) so that commands can be strung together. An example is cat out.txt | wc l

7. The command line prompt must contain the pathname of the current directory.Note:You can assume that all command line arguments (including theredirection symbols, <, >& >>and the background execution symbol, &) will be delimited from other command linearguments by white space -one ormore spaces and/or tabs (see the command line in 4. above).

Project Requirements

1.Design a simple command line shell that satisfies the above criteria and implementsit on the specified Linuxplatform.

2.Write a simple manual describing how to use the shell. The manual should contain enough detail for a beginner to Linuxto use it. Forexample, you should explain the concepts of I/O redirection, theprogram environment, and background program execution. The manualMUST be named readme_docand must be a simple text document capable ofbeing read by a standard Text Editor. For an example of the sort of depth and type of description required, you should have a look at the online manuals for cshand tcsh(mancsh, man tcsh). These shells obviously have much more functionalitythan yours and thus, your manuals dont have to be quite so largeor with such detail. You should NOT include building instructions, included file lists or source code -we can find that out from the other files you submit. This should be an Operators manual not a Developers manual.

3. The source codeMUSTbe extensively commented and appropriately structured to allow your peers to understand and easily maintain thecode. Properly commented and laid out code is much easier to interpret,and it is in your interests to ensure that the person gradingyourproject is able to understand your coding without having to performmental gymnastics!

4.Your solution to the project will be submitted through the Project 2 assignment in Canvas.You will also develop the solution to the project through a GitHub repo. A link to the GitHub repo is to be included as a Canvas project comment.

5. The Canvas submission should contain only source code file(s), include file(s), a makefile(all lower case please), and the readme_docfile (all lowercase,please). No executable program should be included.

6.The makefile(all lowercase, please) MUSTgenerate the binary file myshell(all lower case please). A sample makefilewould be # Joe Citizen, s1234567 -Operating Systems Project 1# CompLab1/01 tutor: Fred Bloggsmyshell: myshell.c utility.c myshell.hgcc -Wall myshell.c utility.c -o myshellThe program myshellis then generated by just typing makeat the command line prompt.Note:The fourth line in the above makefile MUST begin with a tab.

7. In the instance shown above, the files in the submitted directory wouldbe: makefilemyshell.cutility.cmyshell.hreadme_doc

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!