Question
The Shell or Command Line Interpreter is the fundamental User interface to an Operating System. Your third project is to write a simple shell -
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
To start this the code:
** This program was compiled and run on alpha.fdu.edu ** but it should work on any UNIX system. ** ** To compile and run: ** >>cc exammpleshell.c -o ashell ** >>ashell ** OR ** >>cc exampleshell.c ** >>a.out */ #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 = "id number> ";
/* ** 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;
}
i need to declare the 5 property in the question above.
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