Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SHELL.CPP I need to implement the display prompt and the read-in command methods. How would I go about doing that. This is what I have

SHELL.CPP

I need to implement the display prompt and the read-in command methods. How would I go about doing that. This is what I have so far please see my code below.

The program below is written in C++

Any help would be appreciated!!

#include #include #include #include

//I need to know how to implement display prompt here void prompt(){ //create initial display screen }

//I need to know how to implement read in prompt here

int main(){

//two arrays that hold the command //one array of pointers to hold parameters char cmd[100], command[100], *parameters[20]; //environment - assumption all variables are in /bin char *env[]={(cahr *) "PATH=/bin",0}; //while loop - aka driver while(1){ //display prompt prompt(); //read in from command line read(command,parameters); //fork()is used to run in parallel creating child copies if(fork()!=0) wait(NULL); else{ //copy bin directory strcpy(cmd, "/bin/");

//concatenate what the user enters strcat(cmd, command);

//execute command execve(cmd, parameters, env); }//end else

//terminate when user enters exit if(strcmp(command, "exit")==0) }//end while loop

}//end main

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

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions

Question

=+what kinds of policies and practices should be developed?

Answered: 1 week ago

Question

=+ Of the HR issues mentioned in the case,

Answered: 1 week ago