How to design a c program to serve as a shell interface

Assignment Help C/C++ Programming
Reference no: EM131099610

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 <stdio.h>
#include <unistd.h>
#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.

Reference no: EM131099610

Questions Cloud

Third evaluation concerns staff scheduling : The third evaluation concerns staff scheduling. Some of the customers have complained that service is slow. The restaurant is open from 11:00 a.m. to midnight every day of the week. Tony divided the workday into five shifts.
How implement and communicate your brand positioning : MKT10007 Fundamentals of Marketing. Summarize how your recommended Marketing Mix will implement and communicate your Brand Positioning
How to compete in individual country markets : How to compete in individual country markets? The standardization of specific competitive marketing variables (attitudes, etc you introduced) across country markets (Liberia vs. USA).
Explain why you used either the cpi data or the gdpd data : Explain why you used either the CPI data or the GDPD data - Draw a supply/demand diagram of the US Treasury bond market to illustrate the effects on it of the developments cited in part A.
How to design a c program to serve as a shell interface : 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
Minimum bid and expected value of the minimum bid : A government agency is putting a large projector out for low bid. Bids are expected from 10 different contractors and will have a normal distribution with a mean of $3.5 mil and a standard deviation of $250,000. Devise and implement a sampling ex..
The management of brinkley corporation : The management of Brinkley Corporation is interested in using simulation to estimate the profit per unit for a new product. Probability distributions for the purchase cost, the labor cost, and the transportation cost are as follows:
Government regulation and standardization : Do you think that too many limitations and restrictions can be placed on parties in a contract? Should there be more government regulation and standardization of contract terms between private parties? Why or why not?
Evaluate the effectiveness of each protection method : Include smartcards as one solution in your analysis, and evaluate whether or not smartcards alone are a proper security solution for protecting personal credentials. Based on your analysis, evaluate the effectiveness of each protection method and ..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  What is taylor rule

What is Taylor rule ?  please write very short paragraph.

  Write program request the user to enter an uppercase letter

Write a program request the user to enter an uppercase letter. Use nested loops to produce a pyramid pattern like this:

  We have to deal with student pilots

We have to deal with student pilots and airplanes. Students have a unique student id, a name, and a year that students are in. Airplanes have a unique airplane id, model, a cruising range

  Write a program at level that will accept a lower case

Write a program at level 3 (Instruction Set Architecture Level) that will accept a lower case letter and output the uppercase version of the letter.

  Compute and display net weekly pay

You need to prepare a C++ program in which you declare variables that holds an hourly wage, a number of hours worked, and a withholding percentage.

  Prepare a program to implement a for loop

Prepare a program to implement a for loop - Program: Write a for loop that sums all the odd integers between 5 and 20 inclusive.

  State the purpose of the function

You may be asked to create a function to solve each of the tasks given below. For each task state the purpose of the function, what the function needs complete the task (input), what the function will send back to the function call (output), and t..

  rewrite that statement in a more readable style.

Give an example statement in C, C++, or Java that is particularly unreadable. Rewrite that statement in a more readable style.

  Implement the tronomino tiling algorithm

Implement the tronomino tiling algorithm,  our program should take an arbitrary input positive integer  k  in the Linux command line and generate a 2 k  * 2 k  board.

  Presented a number of recurrence relations

For this problem set, you will be presented a number of recurrence relations and asked to state their actual time complexity, showing your work in the process.

  C program that compare the time required

Write a C program that compare the time required to compute the product of two 10,000 x 10,000 matrices with and without optimization for locality.

  Design a class named pet

Design a class named Pet, which should have the following fields: Name - The name field holds the name of a pet. and Type - The type field holds the type of animal that is the pet. Example values are "Dog", "Cat", and "Bird"

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd