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