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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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