Create your own shell

Assignment Help Operating System
Reference no: EM134425

Phase 1

The premise of Project 2 is to create your own shell. Your shell will be launchable from a terminal window and act similar to the existing shell.

Groups:  You can work in groups of 1-3 people.  When you turn in the project, make sure every file has the names of everyone from the group.  If you email me the project, just email me the source files.  I will assign grades based on the member names in the source files!  If you want to author each function or section of code via comments to take credit for parts of the program that is fine, but everyone in the group will receive the same grade regardless of the division of labor.

The next two projects will be group projects based off of this project so choose your groups wisely.  You will be allowed to change groups between projects.  If a grad student groups up with undergrads, the project must include Part 6

Part 1

The prompt

Your shell will need to provide a prompt to the user.

46_create your own shell.png

an example of the windows command line prompt

The prompt will be able to display information to the user to provide them with information about their environment.  By default, your prompt should be include the Current Working Directory.You will need to implement a setprompt command in your shell.  An example of the setprompt would be:

setprompt %PWD%$

which then would display a prompt like:

/home/brian/$

Use %PWD% as a substitute for where to insert the current working directory for the prompt string.  After every command is run, you need to display the prompt string to ask for the next user input.

Part 2: 

Implement the "cd" command.  the CD command changes the current working directory of the process.  Your shell should be able to handle commands like the following:

/$  cd bin

          changes from / to /bin/, since we are currently in /

cd /

          changes from CWD to /

/$ cd home/bin

          changes from / to /home/bin, since we are currently in /

 

/home/brian/$ cd ..

          changes from /home/brian/ to /home/ (goes up one directory)

/home/brian/$ cd ../..

          changes from /home/brian/ to / (goes up 2 directories)

 

/home/brian/$ cd /tmp

          changes from /home/brian/ to /tmp/ since /tmp was specified from the root dir

Part 3:

dir command.

Your program will implement a dir command.  This command acts much like the ls  command within the normal linux terminal.  You cannot simply exec the ls command.  you will need to implement it via the opendir and readdir commands.

for example exeucting

/home/$ dir

would output a list of files each on its own line:

  .

  ..

  brian

  tamarra

  matt

  justin

Assuming the home directory contained entries for each of those people.

As arguments to dir you will need to handle:

-s=<option>

          options: name, adate, type

The sort option will sort the results by the specified parameter before printing them out to the screen. (adate is date of last access, type is file type, name is filename)

-r

          recursive.  dir will output the files within the current working directory and every sub directory within, recursively entering deeper and deeper into the directory structure.

Example output:

/home/$ dir -r

  .

  ..

  brian

  tamarra

  matt

  justin

/home/brian/

  .

  ..

  workspace

  documents

  assignments

  tmp

/home/brian/workspace/

  .

  ..

  project1

  project2

  project3

 

/home/brian/documents/

  .

  ..

  lab1

  lab2

  lab3

  midterm

/home/tamarra/

  .

  ..

  projects

  documents

 

finally

-i

          displays a directory listing similar to ls -l, which outputs the files inside a directory with all their attributes.  Attributes must include at least:

          permissions, size, owner, group, access date, modified date, filename

flags can be combined!  so you could have something like

dir -s=name -r -i

which will sort files in a directory by name, and then recursively display detailed information for all files in the directory and all sub directories.  Order of options specified in the argument list can vary.  You could have -s -i -r or -i -r -s or -r -i -s etc.

Part 4

Redirection and piping.  Your shell will need to handle the redirect characters and the pipe character.  for example:

dir -s=name > dirout.txt

would perform the dir command, with the sort option and write the results to the file dirout.txt in the current working directory.

Part 5

Fork and Exec for other functionality.

Since I cannot have you completely rewrite all the tools available through the linux terminal, your shell will need to be able to fork and exec any command it doesn't recognize.  You should use the which command to determine if the entered programs actually exist before attempting to fork and exec.  Display an error if the commands do not exist. 

Your fork and exec must support redirection and piping as well.  I should be able to execute:

dir -i -r | grep cpp > allsourcefiles

Part 6

you will need to implement a cat function similar to the cat in the existing linux terminal.

cat file1 - file2

Output file1's contents, then standard input, then file2's contents to standard output.

cat

Copy standard input to standard output.

For simplicity sake, end the input from standard input when 2 newline characters are read back to back.

Conclusion and other thoughts

It would be nice to include an exit command to terminate your shell.  so if the user types in exit, quit your shell.

Also to be user friendly, you could store the users prompt value, so they wouldn't have to reset it every time they run the program.

Reference no: EM134425

Questions Cloud

Leadership reflections paper : Write a paper on Leadership Reflections Paper Summarizes and reflects upon leadership ideas gleaned from the four required readings
Review the scenarios from the steven pinker''s article : Review the scenarios from the Steven Pinker's article devised by Jonathan Haidt.
Identify the major participants in the financial system : Analyze the USA financial meltdown that happened in 2008-2009. This crisis was partially caused by the reward systems that were in place for participants in the financial system. Identify the major participants in the financial system.
Research jetblue and discuss its strategy using framework : Research JetBlue and discuss its strategy using the framework presented in Hambrick and Frederickson's article.
Create your own shell : The premise of Project 2 is to create your own shell. Your shell will be launchable from a terminal window and act similar to the existing shell.
Marketplace and practice of information technology : Prepare a report on the marketplace and practice of Information Technology
What are entity-relationship diagrams : What are entity-relationship diagrams, and how are they used? Discuss the ethical issues to consider when planning a database.
What is the most probable cause of m.g.s signs and symptoms : What is the most probable cause of M.G.'s signs and symptoms? What are general complications of this disorder, and how would one assess for their occurrence?
What is the standard deviation of this portfolio : What is the standard deviation of this portfolio? What is the expected return of a portfolio of two risky assets if the expected return E(Ri)

Reviews

Write a Review

Operating System Questions & Answers

  Design and programming

Use the semaphore methods to control the concurrency of the solution

  Analyse the different methods for collecting data

Analyse the different methods for collecting data Explain by taking examples 3 types of Sampling techniques.

  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.

  Multilevel feedback queues and fcfs

What (if any) relation holds between the following pairs of sets of algorithms (a) Priority and SJF (b) Multilevel feedback queues and FCFS

  Deadlock avoidance and scheduling

Deadlock Avoidance and Scheduling

  Explain deadlock-avoidance system

What is the difference between a safe state and an unsafe state in a deadlock-avoidance system?

  What is the main advantage of multiprogramming

What is the main advantage of multiprogramming How does the distinction between the monitor mode and user mode function as a rudimentary form of protection (security) system What is the difference between a trap and an interrupt? What is the u..

  Issues with trusted platform module

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

  Give three advantages of virtual machine

In different communications models, communication may take place using either "message passing" or "shared memory". Distinguish between "message passing" and "shared memory", illustrating your answer with a diagram Give three advantages of virt..

  Define the term context switch

Define the term context switch. Explain how context switching takes place. (use a diagram, with two processes)

  Explain the concepts of consumable and reusable resources

Explain the concepts of consumable and reusable resources

  Vliw processor

VLIW processor - assembler

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