Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Practice UNIX system calls by writing a custom shell interpreter in JAVA. Question 1) Implement a shell, and provide the source codes. Your shell should

Practice UNIX system calls by writing a custom shell interpreter in JAVA.

Question 1) Implement a shell, and provide the source codes.

Your shell should prompt the user for a command. The command prompt must be "AB>" where A is the first letter of your first name and B is the first letter of your last name.

The shell executes a command, if it is an external command, by fork(2)-ing the main process and having the child execute the command using a function of the exec(3) family. The parent should use a function of the wait(2) family to wait for the completion of the child process before continuing. If the command is a built-in, the shell execute it without using fork(2) and exec(3).

The shell must be able to handle internal commands cd, help, exit and an additional built-in command of your choice.

If the user enters the command exit, the main process should not call fork(2) and instead just exit the program successfully.

Question 2) Add an ability to handle the history internal command, and provide the source codes.

The history command will print the list of the commands executed by user or message indicating the history is empty. Practice the command for better understanding before designing a solution.

The shell needs to keep every command in a data structure in the same order of execution. For this purpose, you may want to implement a simple singly linked list.

!!: This command will execute the last command the user executed. This command should not be added to the history list.

!n: This command tells the shell to execute the n-th command in the history. If no such command exists it should display an error. This command should not be added to the history list. You may find the function atoi(3) helpful in parsing this command.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

3. Would you say that effective teamwork saved their lives?

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago