Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 - List the contents of directory . c. environ - List all the environment strings. d. run prog p1 p2 execs to prog passing the parameters p1 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

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 #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 = "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

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

More Books

Students also viewed these Databases questions

Question

Recognize the power of service guarantees.

Answered: 1 week ago