Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I really appreciate in advance. C++ or C language Operating system programming 1. The goal of this programming assignment The primary goal of this assignment

I really appreciate in advance.

C++ or C language Operating system programming

1. The goal of this programming assignment

The primary goal of this assignment is to understand and gain some familiarity with the system call interface in Unix Environment. In this assignment you will be implementing your own command line interpreter like a Unix shell program. YOU ARE NOT IMPLEMENTING COMMANDS! YOUR program should just FORK off programs and EXECUTE them.

2. Requirements

(1) Programming language: You have to use either C or C++ to develop your program.(2) Running Environment: Your program should be compiled at CSEGRID and be able to be tested without errors.

3. The implementation details

. (1) Backgrounds: The command line interpreter, called a shell, is an application program that gets commands from a keyboard and uses the system call interfaces to invoke OS functions.

. (2) Your shell should support followings:

(a) Support exit or stop your shell commanda) Example(s): exit

(b) Support commands with no arguments.a) Examples: ls, pwd, whoami and hostname

(c) Support commands with arguments:a) Examples: ls l, ls fx, ps aux ,date u, cd directory, etc.

(d) A command, with or without arguments, whose output is redirected to a file a) Examples: ls > foo, ls -Fx > foob

(e) A command, with or without arguments, whose input is redirected from a file a) Examples: sort < testfile

(f) Supporting a sequence of programs that communicate through a pipe.a) Examples: ls | wc

(g) Display error messages if the typed command has errors or cant be found

4. Hint

Your shell should isolate itself from program failures by creating a child process to execute each command specified by the user. For example, the tar cvf cli5678 program1 command is executed by a child of the process executing the shell, myshell.

% tar cvf cli5678 program1 myshell

You might consider the following functions to build myshell:

. (1) Printing a prompt when myshell is begun, it display its own string as its own prompt. For example, myshell>

. (2) Getting command line To get a command line, the shell performs a blocking read operation so that the process that executes the shell will be blocked until the user types a command line in response to the prompt. When the user enters the command, the command line string should be returned to the myshell.

. (3) Parsing the command: Take the user command and divide it into command and arguments as well as checking errors.

. (4) Finding the file The shell provides a set of environment variables for each user such as PATH. The PATH environment variable is an ordered list of absolute pathnames that specifies where the shell should search for command files.

. (5) Create a child process and launch the command Once the command and arguments are prepared, create a child process to execute the command with its arguments and wait until the command is completed.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions