Question
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
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