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

Modern Day Sin: The Inferno by Dante

Choose something you feel is typical of a modern day sin and put it into dantean context. While writing think of appropriate contrapasso, how does it fit with Dante’s three divisions of hell, where in Dante’s inferno should the sin be located, what kind of demonic figure should be present

Fourth Amendment Application, the “Case of the Bad Boyfriend” [WLOs:

Fourth Amendment Application, the “Case of the Bad Boyfriend” [WLOs: 2, 3] [CLOs: 1, 3, 4] Prior to beginning your written assignment, read Kim’s Fourth Amendment (Links to an external site.) article, Machado’s Fourth Amendment (Links to an external site.) article, view the Fourth Amendment: Exceptions to the Warrant Requirement (Part I) (Links

Discussion 2 Sheye Joseph Subscribe Everett

Discussion 2 Sheye Joseph Subscribe Everett Rogers’ framework in “Diffusion of Innovations” remains highly relevant today, serving as a critical tool for understanding how modern technologies and ideas permeate societies. His model hinges on five key elements: the innovation itself, communication channels, time, the social system, and the adopter categories.

= When we ask a question like, “Is it ethical

= When we ask a question like, “Is it ethical to web scrape a website?”, the audience is seeking specific knowledge on the topic. For the discussion forum, what ethical considerations must be taken into account when conducting web scraping.  – response should be a minimum of two paragraphs and

In many cases, advertisers sell particular ideas or images along

  In many cases, advertisers sell particular ideas or images along with the product being advertised. Car advertisements, for instance, may emphasize the status of a particular vehicle, the adventurous or thrilling aspects of driving the car, or the many advanced safety features designed to keep the driver and passengers

Reply 1 Theoretical and conceptual frameworks are terms in which

Reply 1   Theoretical and conceptual frameworks are terms in which are used interchangeably in research. Green (2014) mentions that some research methods do not use a theoretical or conceptual framework in their designs. All of my articles state no types of framework used nor does it use any specific

watch the film BURT’S BUZZ Questions to consider while you

watch the film BURT’S BUZZ  Questions to consider while you are watching the movie: What motivated Burt to become an entrepreneur? What was Burt’s relationship with Roxanne? How did it change over the years? What made the business successful? How could Burt have better protected himself? In the end, would

Human Rights – 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.

You are tasked with identifying a standardized assessment instrument/tool to

  You are tasked with identifying a standardized assessment instrument/tool to measure the disorders ( Social Phobia, Panic Disorder…) Instrument/ Tool criteria:   For each assessment, you are tasked with selecting, you will identify an instrument and:   List what DSM diagnosis the tool/instrument is used for   Identify an

Learning Goal: I’m working on a health & medical question

 Learning Goal: I’m working on a health & medical question and need an explanation and answer to help me learn.In this discussion I want you to focus on the role of public health in food (e.g. food safety, food sovereignty). https://youracademichelper.com/post-the-first-half-of-the-written-part-of-your-final-project-for-peer-review-du/art-architecture/ For your post, please write 1-2 paragraphs (4-5 sentences

Please free to use references and also use the power

Please free to use references and also use the power point attached Based on what you have read in the below attached PPT Chapter 1&2, please explain how data analytics applies to your current or future role?  What value can data analytics bring to your position? Please share your thoughts.

Module 04 Content Click here to open a word document

  Module 04 Content Click here to open a word document with the assignment instructions and rubric. NUR2356_Module 04 Written Assignment_1220-1.docx Submit your completed assignment by following the directions linked below. Please check the Course Calendar for specific due dates.Save your assignment as a Microsoft Word document. (Mac users, please remember to append

Avoiding the filter bubble – 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.

Describe Covid 19 and justify why you believe it is

  Describe Covid 19 and justify why you believe it is a global issue rather than a local or national one. Thoroughly discuss regions of the world that have been more/less heavily impacted by this crisis. This section will require you to dig into the data an examine trends in

Select one of Hamlet’s soliloquies from the play and analyze how it

Requirements: • Written communication: Written communication should be free of errors that detract from the overall message. • APA formatting: Should be formatted according to APA (6th edition) style and formatting. • Length: 6–7 typed and double-spaced pages. Font and font size: Times New Roman, 12 point. Read Shakespeare’s Hamlet.

Help- Remember to respond to two peers while being respectful

Help- Remember to respond to two peers while being respectful of and sensitive to their viewpoints. Consider advancing the discussion in the following ways: • Post an article, video, or visual related to the development of the social self to reinforce a peer’s idea or challenge them to see their

1) Taking the role of a financial planner, let’s say

  1) Taking the role of a financial planner, let’s say you have a client (named Jane), who is a single mother of two. Jane is 28 years old. She makes 80,000 per year which is expected to grow 2% per year until age 67. Due to attractive interest rates