Question: this is the code: ** To compile and run: ** >>(g)cc exammpleshell.c -o ashell ** >>ashell ** OR ** >>(g)cc exampleshell.c ** >>a.out */ #include

this is the code:
** To compile and run: ** >>(g)cc exammpleshell.c -o ashell ** >>ashell ** OR ** >>(g)cc exampleshell.c ** >>a.out */ #include #include #include
enum { MAXLINE = 200 };
/* ** This function ** processes the ** command. */ void processLine( const char * const s ) { /* ** Do not hesitate ** to declare lots of ** local variables. ** The optimizer ** removes them ** but can make the ** program more ** readable. */ const char * const stopStr = "quit"; const int sLen = strlen(stopStr); const int sVal = strncmp(s, stopStr, sLen);
/* ** Output command. */ printf("Command received = %s ", s);
/* ** If stop string entered, ** exit(0). */ if(!sVal) exit(0);
}
int main() {
char line[MAXLINE];
/* ** When a const ** is needed declare ** it as such. */ const char * const prompt = "Go FDU > ";
/* ** Get a command line, parse it and process it. ** This program exits via an exit(0) in the ** processLine() function. */ while(1) { const int j = fputs(prompt, stdout); const char * const c = fgets(line, MAXLINE, stdin); processLine(line); } return 0;
}
The Shell or Command Line Interpreter is the fundamental User interface to an Operating System Your third project is to write a simple shell - myshell - that has the following properties: 1. The shell must support the following internal commands: a. clr - Clear the screen. b. dir - List the contents of directory . c. environ - List all the environment strings. d. run prog pl p2... exec's to prog passing the parameters pl p2. e. quit - Quit the shell. 2. All other command line input is interpreted as program invocation, which should be done by the UNIX system) function 3. For option d. you may either overlay the shell or overlay a forked/child process with the shell wait(.)ing until the spawned command has finished before continuing. 4. The command line prompt must contain your UNIX username. Example: wp663000>> Project Requirements 1. Design a simple command line shell that satisfies the above criteria and implement it on the alpha.fdu.edu UNIX platform. 2. The source code MUST be extensively commented and appropriately structured to allow your peers to understand and easily maintain the code. Properly commented and laid out code is much easier to interpret, and it is in your interests to ensure that the person marking your project is able to understand your coding without having to perform mental gymnastics! 3. The submission should contain only 1 source code file. The person marking your project will be building your shell program from the source code provided. If the submitted code does not compile it cannot be marked! The Shell or Command Line Interpreter is the fundamental User interface to an Operating System Your third project is to write a simple shell - myshell - that has the following properties: 1. The shell must support the following internal commands: a. clr - Clear the screen. b. dir - List the contents of directory . c. environ - List all the environment strings. d. run prog pl p2... exec's to prog passing the parameters pl p2. e. quit - Quit the shell. 2. All other command line input is interpreted as program invocation, which should be done by the UNIX system) function 3. For option d. you may either overlay the shell or overlay a forked/child process with the shell wait(.)ing until the spawned command has finished before continuing. 4. The command line prompt must contain your UNIX username. Example: wp663000>> Project Requirements 1. Design a simple command line shell that satisfies the above criteria and implement it on the alpha.fdu.edu UNIX platform. 2. The source code MUST be extensively commented and appropriately structured to allow your peers to understand and easily maintain the code. Properly commented and laid out code is much easier to interpret, and it is in your interests to ensure that the person marking your project is able to understand your coding without having to perform mental gymnastics! 3. The submission should contain only 1 source code file. The person marking your project will be building your shell program from the source code provided. If the submitted code does not compile it cannot be marked