Earn Higher Grades With Instant Assignment Help.Ask Question!

C Programming
(5/5)

When the shell is invoked by executing the executable blazersh, it should provide a prompt blazersh> and waits for any input from the keyboard.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

The Shell or Command Line Interpreter is the fundamental user interface provided by an operating system. Implement a simple shell called blazersh that provides the following functionality:

1. When the shell is invoked by executing the executable blazersh, it should provide a prompt blazersh> and waits for any input from the keyboard.

2. Any input entered will be interpreted as a program to be executed and the shell should create a new process corresponding to the input entered using fork/exec. You can assume that the newline character denotes the end of the input. If a newline character is entered without any other text or followed by white space, the shell should just display the prompt on the next line. The new process created should be able to read keyboard input and display output to the terminal. You can assume that these programs are executed only in the foreground, i.e., the shell program will wait for the child process to complete and when the child process completes successfully it will display the command prompt.

3. The simple shell program should intercept Control-C and Control-Z characters and perform the appropriate action on the child process instead of the parent process (i.e., interrupt the child process instead of interrupting the parent process when Control-C is entered and stop the child process instead of stopping the parent process when Control-Z is entered). You should print a message saying the child process has been interrupted or stopped.

4. The shell program should support I/O redirection for both standard input and standard output. For example: ./myprog arg1 arg2 < inputfile > outputfile.  The program myprog with command-line arguments arg1 and arg2, uses inputfile file for standard input file stream and sends standard output file stream to the file outputfile. If the file outputfile does not exist, a new file should be created and if the file outputfile exists, it should be over-written. You can assume that white space will serve as the delimiter for the I/O redirection symbols < and >.

5. In addition to creating a new process corresponding to each command entered, the shell should also support the following internal commands:

a. list – list all the files in the current directory. The default directory is the directory where the shell program was invoked or the directory specified by the PWD environment variable.

b. cd <directory> – change the current directory to the <directory>. The default directory would be the directory where the shell program was invoked. This should also change the PWD environment variable.

c. jobs - lists the processes along with their corresponding process id that were stopped when the user enters Control-Z. Whenever the user enters the Control-Z character, the simple shell program must keep track of processes that are stopped and the jobs command should list such processes.

d. continue <pid> - sends the continue signal to the process with process id <pid>. You can obtain the <pid> to send the continue signal using the jobs commands.

e. help – display the internal commands and a short description on how to use them.

f. quit – quit the shell program.

Note that you should not use fork/exec to implement the internal commands, you have to implement this functionality in the parent process (the simple shell program).

 

1. Implement the internal command history that displays all the previous command entered into the shell program. The shell should save all commands entered in a log file called blazersh.log and this file must be written in the directory where the shell program was invoked. The log command could just display the contents of this file
2. If the shell is invoked with a command-line argument which provides the name of the input file that contains the various commands the shell should execute, then the shell should execute these commands in the order specified in the input file and exit when the end-of-file is reached. If the shell is invoked without the command-line argument it should display the command prompt and wait for user input. The input commands file could have both internal commands and external programs that the simple shell should execute.

 

redirection for both standard input and standard output. For example: ./myprog arg1 arg2 < inputfile > outputfile.  The program myprog with command-line arguments arg1 and arg2, uses inputfile file for standard input file stream and sends standard output file stream to the file outputfile. If the file outputfile does not exist, a new file should be created and if the file outputfile exists, it should be over-written. You can assume that white space will serve as the delimiter for the I/O redirection symbols < and >. 5. In addition to creating a new process corresponding to each command entered, the shell should also support the following internal commands: a. list – list all the files in the current directory. The default directory is the directory where the shell program was invoked or the directory specified by the PWD environment variable. b. cd <directory> – change the current directory to the <directory>. The default directory would be the directory where the shell program was invoked. This should also change the PWD environment variable. c. jobs - lists the processes along with their corresponding process id that were stopped when the user enters Control-Z. Whenever the user enters the Control-Z character, the simple shell program must keep track of processes that are stopped and the jobs command should list such processes. d. continue <pid> - sends the continue signal to the process with process id <pid>. You can obtain the <pid> to send the continue signal using the jobs commands. e. help – display the internal commands and a short description on how to use them. f. quit – quit the shell program. Note that you should not use fork/exec to implement the internal commands, you have to implement this functionality in the parent process (the simple shell program).   1. Implement the internal command history that displays all the previous command entered into the shell program. The shell should save all commands entered in a log file called blazersh.log and this file must be written in the directory where the shell program was invoked. The log command could just display the contents of this file. 2. If the shell is invoked with a command-line argument which provides the name of the input file that contains the various commands the shell should execute, then the shell should execute these commands in the order specified in the input file and exit when the end-of-file is reached. If the shell is invoked without the command-line argument it should display the command prompt and wait for user input. The input commands file could have both internal commands and external programs that the simple shell should execute.

 

Attachments:
(5/5)

Related Questions

CSI 1420 Introduction to C Programming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu

The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Assignment To Be Done By Our ExpertsGet A+ Grade Solution Guaranteed

expert
joyComputer science
(4/5)
12 Answers Hire Me
expert
Robert DLaw
(4.8/5)
685 Answers Hire Me
expert
Dr Samuel BarberaStatistics
(5/5)
567 Answers Hire Me
expert
Tutor For YouEconomics
(5/5)
938 Answers Hire Me