The Shell or Command Line Interpreter is the fundamental User interface to an Operating System. write a simple shell - myshell - that has the following properties: Supported commands: The shell must support the following internal commands: cd- change the current default directory to. If theargument 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. clr - clear the screen. dir- list the contents of directory environ - list all the environment strings echo - display on the display followed by a new line (multiple spaces/tabs may be reduced to a single space) help - display the user manual using the more filter pause - pause operation of the shell until 'Enter' is pressed quit - quit the shell 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)

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
Question

The Shell or Command Line Interpreter is the fundamental User interface to an Operating System. write a simple shell - myshell - that has the following properties:

Supported commands: The shell must support the following internal commands:

  • cd- change the current default directory to. If theargument 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.
  • clr - clear the screen.
  • dir- list the contents of directory
  • environ - list all the environment strings
  • echo - display on the display followed by a new line (multiple spaces/tabs may be reduced to a single space)
  • help - display the user manual using the more filter
  • pause - pause operation of the shell until 'Enter' is pressed
  • quit - quit the shell
  • 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)

All other command line input is interpreted as program invocation which should be done by the shell forking and execing the programs as its own child processes. The programs should be executed with an environment that contains the entry: parent=/myshell where/myshell is as described in the last bullet point. above.

Batch Mode: The shell must be able to take its command line input from a file. i.e. if the shell is invoked with a command line argument:

BASH
myshell batchfile
 
then batchfile is 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 it solicits input from the user via a prompt on the display.
 
I/O redirection:The shell must support i/o-redirection on either or both stdin and/or stdout. i.e. the command line:
BASH
programname arg1 arg2 < inputfile > outputfile
will execute the program programname with arguments arg1 and arg2, the stdin FILE stream replaced by inputfile and the stdout FILE stream replaced by outputfile.
stdout redirection should also be possible for the internal commands: dir, environ, echo, and help.
With output redirection, if the redirection character is > then the outputfile is created if it does not exist and truncated if it does. If the redirection token is >>then outputfile is created if it does not exist and appended to if it does.
 
Background execution: The shell must support background execution of programs. An ampersand , or & character, at the end of the command line indicates that the shell should return to the command line prompt immediately after launching that program whilst it continues to run in the background.
 
Miscellaneous: The command line prompt must contain the pathname of the current directory. Note: you can assume that all command line arguments including the redirection symbols, <, > and >> and the background execution symbol, &will be delimited from other command line arguments by white space - one or more spaces and/or tabs
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 5 images

Blurred answer
Knowledge Booster
Linux
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