Assignment 3 – Improving a Shell In this assignment you

 

Assignment 3 – Improving a Shell

In this assignment you shall take an existing implementation of a shell program and add some small improvements to it.

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 (30 marks)

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 (30 Marks)

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 – (20 marks)

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.

Detailed Submission Instructions

This assignment is basically like every other assignment you’ve ever done in CS… but just as a reminder:

The handin key for this exercise is: prac3. The following SVN commands will enable you to make a repository for this assignment. Please note the following:

  • Perform these steps in the order written once only!
  • Replace aaaaaa, where it appears in the commands, with YOUR student id.
  • Some commands are long — they must be typed on one line.

Use the Unix “cd” command to change to the place where you want your exercise directory to be stored, then type these commands:

svn mkdir  –parents -m “spc prac3 start” https://versioncontrol.adelaide.edu.au/svn/a1aaaaaa/2018/s1/spc/prac3

(creates this directory in your svn tree) svn co https://version-control.adelaide.edu.au/svn/a1aaaaaa/2018/s1/spc/prac3 .

(checks out a working copy in your directory) You can now begin work.

You can add a file to the repository by typing the commands:

svn add NAME-OF-FILE svn commit -m “REASON-FOR-THE-COMMIT”

where “reason-for-the-commit” should be some brief text that explains why you changed the code since the last commit. Note that you only need to add a file once — after that, SVN will “know” it is in the repository. You are now ready to commence working on the exercise.

The files you handin must include:

  1. Your C source files as specified above.
  2. A Makefile that will compile your C sources as specified above.

You do not have to include any of the add_one.c files or their variants… that you used for testing we will supply those. 

Make sure you commit your files frequently, in case you have an accident. The University’s SVN repository is very reliable, and is backed up regularly — your computer probably is not… Regular submission is also a good defence against plagiarism by others, since the submissions are dated. We will test the behaviour of your scripts using an automated tester. The tester is thorough, and will find places where your scripts do not work correctly. If it finds an error, it will offer a (vaguish) hint. To encourage you to test your own work, the tester will not be fully available in the first few days before the exercise deadline. 

The websubmission system will award up to 6 marks automatically. We will manually check the code for style and commenting and for code associated with the optional bonus exercise. Note that we reserve the right to deduct marks if your code does anything egregious or games the system to obtain marks.

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

word count 1000 One way of exploring issues related to

 word count 1000 One way of exploring issues related to child development is by analyzing media aimed at children. In the themes and conflicts of a children’s movie, you should be able to identify issues related to relationships, negotiating diversity, coping with crisis, and other developmental tasks relevant to your

Digital Communication: How does the Harry Potter film series utilize

OVERVIEW The goal of this project is to thoroughly research a topic within digital communication and present findings using relevant technology. INSTRUCTIONS Part 1: Choose a digital communication topic to research in-depth that includes at least one aspect of social media. You should answer a question about a controversial digital

750 words This assignment focuses on a case study, The

750 words This assignment focuses on a case study, The Case of Marie, which you  completed as a part of this unit’s studies. This case involves an  ethical dilemma with a diverse family, and the dilemma itself, like most  ethical issues in group work, is potentially two-fold: The dilemma among

1. Find an article, podcast, or news clip online or

1.   Find an article, podcast, or news clip online or in a newspaper or magazine that discusses research relevant to child-rearing. The article should be of interest to you and published in a source that would be available to many parents. (To find your article, browse a weekly news magazine or

Training Program on Conflict Resolution Overview Due to a recent

Training Program on Conflict Resolution Overview Due to a recent increase in the number of cases involving interpersonal and interdepartmental conflict in your organization, HR has made the decision to develop a training program on conflict resolution. Instructions Prepare a 10–12 slides PowerPoint presentation with speaker notes that includes each

Assume that you have been hired by a small veterinary

Assume that you have been  hired by a small veterinary practice to help them prepare a contingency  planning document. The practice has a small LAN with four computers and  Internet access. Prepare a list of threat categories and the associated  business impact for each. Identify preventive measures for each type

Discussion Information: This week is an introduction to keeping a

Discussion Information: This week is an introduction to keeping a professional journal. Starting in Week 3 make sure you have at least two (2) entries in your journal each week using the templates provided as a guide. For Weeks 3 through 6 – You will be contributing to your own

Community assessment – Premium Paper Help

Premium Paper Help is a professional writing service that provides original papers. Our products include academic papers of varying complexity and other personalized services, along with research materials for assistance purposes only. All the materials from our website should be used with proper references.

Ethical Dilemma in Clinical Setting

 A brief paper that summarizes a specific ethical dilemma that reflects an experience you had in a clinical or a personal health care experience (my healthcare experience is I used to work in a rehabilitated and long-term care facility as a nursing assistant – Show the experience more related to nursing assistant

I would also like you to post the most important

  I would also like you to post the most important thing you learned about organizations this term as a result of taking this course.     An Introduction to Organizational Behavior – Table of Contents (lardbucket.org)     this is the text book  I have uploaded screenshots of test book 

REPLY 1 Question A What major change took place in

   REPLY 1 Question A What major change took place in the telephone system after 1984? How did it impact customers, and how does it compare to the telephone networks in use today? Question B What common communication devices are used in homes to connect to the internet and remote

Plato The Allegory of the cave

Description Summarize and respond to Plato’s The Allegory of the Cave. Organize around a strong thesis and top sentences. In this type of essay, your goal is to capture the controlling idea and the supporting details of a text, then respond by deceiving your reaction to the text . Your

As a nurse, you may often feel as if you’re

  As a nurse, you may often feel as if you’re expected to handle everything that comes your way. But as much as you may want to, it’s just not realistic. There’s only so much you can do in a day, and trying to take on too much too often

Read the following scenario and answer the questions below. The

  Read the following scenario and answer the questions below. The Dried Foods Solution Company produces and sells a variety of freeze-dried products in stores throughout the Unites States and Canada. The company does not have an online sales division. Following is a list of job titles for the organization

compares and contrasts two mental health theories: You may choose

  compares and contrasts two mental health theories: You may choose your theories from the textbook or from other sources. Describe each theory, including significant early history about the person who developed the theory and the major ideas and applications of the theory. Describe the ways in which the two theories are