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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!