Solved-Lab 8- Solution

$30.00 $19.00

SPECIFICATIONS We will develop a shell and then add specific features. The goal of this assignment is to write a shell (called mssh which will stand for “my silly shell”). Specifically, you are to write the framework for a Linux shell using the C programming language. Once the shell is executing it will prompt the…

You’ll get a: . zip file solution

 

 
Categorys:
Tags:

Description

5/5 – (2 votes)

SPECIFICATIONS

We will develop a shell and then add specific features. The goal of this assignment is to write a shell (called mssh which will stand for “my silly shell”). Specifically, you are to write the framework for a Linux shell using the C programming language. Once the shell is executing it will prompt the user with the “command?: ” prompt. The user now may issue any command line Linux command.

Here are the general concepts

  1. Using previous labs as a starter. You will prompt with command?: and your shell will exit when the “exit” command is issued.

  1. Your shell has to be bash-syntax compatible. If you divert from this your shell will not pass the input used for testing!

Your shell should be able to handle

  1. Basic commands, such as ls -l, pwd, and others.

  1. You must handle a single pipe such as (ls -l | wc -w)

  1. You must handle two pipes such as (ls -l | cut -c 1,2,3 | wc -w)

  1. The mssh shell is to read input from a file called .msshrc and execute each line in this file as a command. This makes the .msshrc file a batch file. (BASH reads from .bashrc)

  1. Implement aliasing, i.e. define an alias and undefine it.

    1. For example you should be able to make the alias LA which is ls -a

    2. Then you should be able to delete that alias

    1. The .msshrc should be able to have predefined aliases. For example, it would contain alias LA=”ls -a”

  1. Implement a path extension feature, e.g., PATH=$PATH:/data/myprogs. Typically, this is executed when you log in, which means that it would be in the .msshrc file.

  1. Implement a “history” mechanism which will allow access to the last N shell commands where N=HISTORYCOUNT is an environment variable in .msshrc. In .msshrc (if it exists) will be at least two environment variables HISTCOUNT and HISTFILECOUNT. If .msshrc does not exist your program HISTCOUNT will be 100 and HISTFILECOUNT will be 1000 by default. Your program will not crash if .msshrc does not exist. If the file exists the order will be guaranteed. At a minimum you should be able to recall commands by number, for example !513, or !! to re-execute the last command. Similar to bash, the history is stored in a file called .msshrc_history.

  1. Implement cd. Currently, cd will not work in mssh. For any shell to be effective you need to be able to change directories.

  1. Implement redirection (< >). You should be able to redirect stdin and/or stdout.

NOTES

  • Design your code so it is clean and modular. You already have a good start from previous labs.

  • Don’t wait to start you won’t finish if you don’t chip away at this. Don’t try to do everything in one sitting. Pick and choose and work on one topic.

  • Draw a design document before you start coding. You need to understand how all the pieces work together before you start coding. If you don’t you will quickly start breaking things by trying to add the next item.

  • You will need multiple linked lists for this assignment.

GENERAL FLOW

  • The program starts up and checks for:

  1. .msshrc – if it exists reads in the variables – file format is below – doesn’t exist then

default HISTCOUNT and HISTFILECOUNT are used

  1. .mssh_history is loaded if it exists o prompt is displayed

o each command is handled appropriately

o upon exit .mssh_history is written from the executed commands

.msshrc file format – if exists (guaranteed to have HISTCOUNT and HISTFILECOUNT HISTCOUNT=value

HISTFILECOUNT=value

Alias1

Alias2

AliasN

PATH=$PATH:/data/myprogs

TO TURN IN

  • The source code of your program. Name your file that contains main cscd340Lab8.c

  • A Makefile so your code can easily be compiled with a target named mssh

  • Some output captures to illustrate you shell is working. This does not need to be extensive. We will test your code this is just to illustrate you did your own testing. Name this cscd340Lab8.pdf

  • A valgrind run showing you aren’t leaking memory, included in your pdf – cscd340Lab8.pdf

You will submit a zip file named your last name first letter of your first name lab8.zip (Example steinerslab8.zip)