Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Interactive Shell: Write a C/C++ program to implement an interactive shell in which users can execute commands. Call this program myShell. Create an infinite loop

Interactive Shell:

Write a C/C++ program to implement an interactive shell in which users can execute commands. Call this program myShell. Create an infinite loop (while(1)) that repeatedly prompts the user to enter a command (see example output and input below). Consider using fgets() to read a line of input from the user. Before executing the command entered by the user, the command must be compared against the list of supported commands shown here:

dir help vol path tasklist notepad echo color ping

Since some commands require more than one argument (e.g. echo, color, ping), you will need to parse the user input into its arguments. Consider using the strtok() function.

For example:

COMMAND TYPED BY THE USER: ping 192.168.1.1

ARGUMENT 0: "ping" ARGUMENT 1: "192.168.1.1"

If the command in argument[0] is in the list above, your program must execute the command in a child thread via CreateThread().

In other words, create a child thread that executes the command. The parent thread waits for the child to terminate.

If the user types exit or quit, your shell should simply terminate

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

Students also viewed these Databases questions