Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Build a user shell for an operating system (Unix). 1. Read a unix command from the user, execute it, and repeat. Handle the basic commands

Build a user shell for an operating system (Unix).

1. Read a unix command from the user, execute it, and repeat. Handle the basic commands (ls, cat, grep, etc.), with their parameters.

2. Before reading each line, print the prompt string specified by shell variable x1, but if x1 is not set, use the default prompt of $$$$.

3. Support background tasks which run without requiring the user to wait before the next command, specified with &.

4. Accept commands from a file if one is specified; ignore lines starting with #

5. Run commands that name a program anywhere in the path.

6. If a command is not found, print an error message and terminate if input is exit

7. If a command fails (with a non-zero exit value n), print "Program terminated: exit code n."

8. Change directories with the cd command.

9. Support redirection of output with > and support redirection of input with < . Also support simple pipes with | .

Hints

For each command, create a child process that uses execve to run it with its parameters.

Project Constraints:

Use only the following python libraries: os,sys,re

From os, use only: pipe(),fork(),dup() or dup2(),execve() ,wait(),open() or create() and close(),read() and write(), and chdir()

Do not use system(), execvp(), or execvpe().

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

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

What is American Polity and Governance ?

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago