Write a new program which perform all of the shell operation

Assignment Help Operating System
Reference no: EM132320034

Systems Programming

Practise Exam  - Improving a Shell

Preparation - Downloading, Compiling and Testing a simple Shell Implementation

Download and un-compress the following file:

shell.tgz

The contents of the file are C sources that implement a simple shell. The contents are:

• smsh.c - an implementation of a very simple shell program

• smsh.h - a header file with function prototypes

• execute.c - a set of helper functions for running processes within the program

• splitline.c - some text processing utilities

To compile these sources run:

gcc -o smsh1 smsh1.c splitline.c execute.c

To run the shell type:

./smsh1

A prompt of the form ">" will appear and then you can type commands like:

> ls execute.c shell.tgz smsh.h smsh1 smsh1.c splitline.c > wc execute.c

37 113 725 execute.c

The shell is terminated by typing the Control-D key (which signals end of input).

In this assignment you shall add functionality to this shell command. Each part builds upon the last.

Part 1 - Adding the ability to pipe commands to your shell

At the moment smsh1 doesn't support piping of commands. So, for example, if you type:

ls | wc

at the prompt you get:

ls: wc: No such file or directory ls:

|: No such file or directory

Write a new program called smsh2.c that is based on smsh1.c which performs all of the shell operations of smsh1.c but also allows commands to be piped as above so that if you type:

ls | wc

You get output like:

6 6 53

instead. You are free to add and modify files as required to accomplish this task. You must add a Makefile to your submission so that you can compile all the files for part1 by typing:

make part1 and the solution for part 1 can be run by typing: ./smsh2

Note, your program must still cater for all the behaviours that were correct in the original version of smsh1. You may find the lectures on piping useful in completing this part.

Part 2 - redirecton of stdin and stdout

Your version of smsh2 currently doesn't support redirection of output and input of commands such as:

ls > tmp.txt cat < tmp.txt | wc > out.txt

Copy your smsh2.c program from part 1 to smsh3.c so that it can handle redirection of standard input and standard output (don't worry about stderr) using the ">" and "<" symbols.

Again, you are free to add and modify files as required to accomplish this task (without affecting the ability of your code to correctly execute the behaviour required for part 1). You must add a Makefile to your submission so that you can compile all the files for part 2 by typing:

make part2 and the solution for part 2 can be run by typing: ./smsh3

Note, your program must still cater for all the behaviours that were correct in the original version of smsh2.

Part 3 - Adding Globbing -

Your version of smsh3 currently doesn't support wildcards in command lines such as:

ls *.c cat
*.h

Copy your smsh3.c program from part 2 to smsh4.c so that it can handle wilcard symbols in the command line. This expansion of wildcards is called globbing.

Note, you can use the glob system call (type "man -s3 glob" to find out more) that helps you to expand the wildcards to a list of actual filenames.

Again, you are free to add and modify files as required to accomplish this task (without affecting the ability of your code to correctly execute the behaviour required for previous parts). You must add a Makefile to your submission so that you can compile all the files for part3 by typing:

make part3 and the solution for part 3 can be run by typing: ./smsh4

Note, your program must still cater for all the behaviours that were correct in the original version of smsh3.

Attachment:- Programming files.rar

Reference no: EM132320034

Questions Cloud

What is the rationale for conducting mass layoffs : What is the rationale for conducting mass layoffs through electronic communication or other, impersonal methods? Do you see any advantages?
Do you think that experience can be replicated in a work : What factors do you recall that made it such a positive experience? Do you think that experience can be replicated in a work
Compare and contrast linear and logistic regression methods : Compare and contrast linear and logistic regression methods. Provide examples of real-life applications of each of these methods.
Relation of earthquakes to plate tectonics and faults : Descriptions of hazards associated with earthquakes in Los Angeles. Relation of earthquakes to plate tectonics and faults in Los Angeles
Write a new program which perform all of the shell operation : Write a new program called smsh2.c that is based on smsh1.c which performs all of the shell operations of smsh1.c but also allows commands.
What is the process used at your current employer : Looking back, what is the process used at your current employer (or previous if you are not currently employed) for onboarding?
Management in the project management processes : How can the application of change management principles impact the project as a whole?
Summarize the relevant geologic history of the region : Summarize the relevant geologic history of the region, Discuss the formation and age of the feature, Discuss the role of erosion and/or weathering on feature.
Some of its organizational practices : A construction company has determined that some of its organizational practices can cause serious health hazard to its employees?

Reviews

Write a Review

Operating System Questions & Answers

  Implementation of algorithms for process management

The Shortest Job Next (SJN) algorithm queues processes in a way that the ones that use the shortest CPU cycle will be selected for running rst.

  Develop a user mode command interpreter

Develop a user mode command interpreter which support list-short.

  Memory allocation in operating system

Analysis and implementation of algorithms for memory allocation in operating system, Explain First- t and best- t methods are used in memory allocation in operating systems.

  Stand alone child process

Forking the child process

  Write a multi-threaded program

Write a multi-threaded program to solve producer and consumer problem

  Marginal and average cost curves

n a competitive market place (pure competition) is it possible to continually sell your product at a price above the average cost of production.

  Simulating operating systems scheduling

Simulate the long-term scheduler, the short-term scheduler and the I/O scheduler of the computer using the First-Come-First-Serve algorithm.

  Issues with trusted platform module

Research paper discussing the issues with Trusted Platform Module (TPM)

  Threads

Explain a complication that concurrent processing adds to an operating system.

  Design and programming

Use the semaphore methods to control the concurrency of the solution

  Virtual machines

Virtual machines supported by a host operating system

  Discuss an application that benefits barrier synchronization

Discuss an application that would benefit from the use of barrier synchronization

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