Question
C++ Help. hi Please help. I need C++ code Please include how to run the code on Mac terminal Your project is to develop/write a
C++ Help. hi Please help. I need C++ code
Please include how to run the code on Mac terminal
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
-
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
Page 2 of 10
2. 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=
3.
The shell must be able to take its command line input from a file. That is, if the shell is invoked with a command line argument:
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.
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=
The shell must be able to take its command line input from a file. That is, if the shell is invoked with a command line argument:
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.
4. The shell must support I/O - redirection on either or both stdin and/or stdout. That is, the command line
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, & 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.
5. The shell must support background execution of programs. An ampersand (&) at the end of the command line indicates that the shell should return to the command line prompt immediately after launching that program.
Page 3 of 10
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 the redirection symbols, <, > & >> and the background execution symbol, &) will be delimited from other command line arguments by white space - one or more spaces and/or tabs (see the command line in 4. above).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started