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

  Declare and define constructor

Declare and define constructors and Declare and define destructors - Describe what is an attribute or data member of a class

  Translate than c source code

Why does Ada take so much more time to translate than C source code? What phase of the Ada translation takes the longest?

  Sum of all odd numbers between a and b

The sum of all odd numbers between a and b (inclusive). Where a and b are read in by the user - Can you find the error in this code.

  Program to calculate a mortgage.

The user should be told what the invalid entry was and why it was invalid if they enter a zero or negative amount. They should then be prompted again to reenter a valid amount.

  Direct cost variance analysis

Problem 2: Direct Cost Variance Analysis  Ken Co. uses standard costing for accounting. Following is the standards for production of its only product:Direct material: 18 pounds at $25 per pound

  Optimize the preceding code for kathy

Optimize the preceding code for Kathy and find out the errors (if any). What would be the output of the preceding code, if the first number is 46 while the second number is 37?

  The reverse of each word, and a palindrome checker

give us the first letter of each word, the first half of each word, the reverse of each word, and a palindrome checker to see if the word is a palindrome.

  Explain the steps for building a rudimentary management

Explain the steps for building a rudimentary management system.

  Find the occupation and the score of each player

We saw in class how to represent a binary search tree in Prolog. Write a predicate lca (K1, K2, T) which allows one to find the smallest common ancestor of K1 and K2 in the tree T. The predicate lca shall print the subtree T such that the root is ..

  Write a function named dietoss that simulates the tossing

Write a function named dieToss that simulates the tossing of two dice. When you call the function, it should generate two random numbers ranged in 1 to 6 and return the sum of the die's numbers. In the mail program, ask user how many times the dice s..

  State private portion of class to model the item

In c++ state the private portion of a class to model the given item: a class Date for dates consisting of a month, day and year. a class PhoneNumber for a telephone numbers consisting of area code, local exchange, and number.

  Finish or complete the coding for me because syntax and code

finish or complete the coding for me. because syntax  and codes, so the proram can execute correctly

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