Inthisprojectyouwilllearnhowtodesignacprogramtoserveasa


Lab Instruction

In this project, you will learn how to design a C program to serve as a shell interface that accepts user commands and then executes each command in a separate process. Your program should parse the command that is entered by a user including arguments of a command by using strtok system call. The strtok() function breaks a string into a sequence of zero or more nonempty tokens. For example, "ls" is the command "-l" is an argument of "ls" command. Separate tokens can be stored in an array of character strings (args in Figure 3.36). You can find the description of this programming project and an extended start code at the bottom of the page if you want to use.

#include
#include
#define MAX LINE 80 /* The maximum length command */
int main(void)
{

char *args[MAX LINE/2 + 1]; /* command line arguments */
int should run = 1; /* flag to determine when to exit program */
while (should run) {
printf("osh>");
fflush(stdout);

/**
* After reading user input, the steps are:
* (1) fork a child process using fork()
* (2) the child process will invoke execvp()
* (3) if command included &, parent will invoke wait()
*/

}

return 0;

}

Figure 3.36 Outline of simple shell.

Submission Instruction:

1. Replace osh> prompt illustrated in the textbook with comp322> prompt.
2. Run pwd command after comp322> prompt and take a screenshot.
3. Run ls -l command after comp322> prompt and take a screenshot.
4. Implement a print statement which shows this line after each run of your program. "Program run by userID at currentTime" (Refer to Programming Project 1 for how to retrieve userID and currentTime).

5. Substitute the file name with K200LoginName.c, compile and execute the shell (change the file name in your makefile if you decide to use make).

Upload .c file and the PDF file.

The .c file should be named as K200LoginName.c.

The PDF file comprising your screenshots needs to be named following this format, K200LoginName_YourLastName.pdf

Both files need to be submitted here in Moodle.

Submission failed to meet the submission requirement will not be graded. Grade may be forfeited.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Inthisprojectyouwilllearnhowtodesignacprogramtoserveasa
Reference No:- TGS01477628

Expected delivery within 24 Hours