Question

Project 1: Implementing a Shell 1 Overview In this individual project you will have to design and implement a simple shell co

had started the firefox web browser, and suspended it using Control-Z, then mysh# bg $4 should let the browser continue runni

Project 1: Implementing a Shell 1 Overview In this individual project you will have to design and implement a simple shell command interpreter called mysh. The basic function of a shell is to accept lines of text as input and execute programs in response. The shell must be able to execute built-in commands in a process different from the one executing mysh. 2 Requirements When first started, your shell should initialize any necessary data structures and then enter a loop of printing a prompt, e.g. 'mysh#, reading any commands entered by the user and executing them. 2.1 Simple execution of commands mysh executes a program in the foreground, waits for it to terminate, and then resumes control, e.g. mysh# vi would launch the vi editor, the user can then perform text processing and after the user quits vi, control is returned back to the shell. The user shouldn't have to type in the full path to executables as long as they are within the search path specified in the environment by the PATH variable. In your initial implementation mysh should spawn a child process and block wait for the child to terminate. The relevant system calls here are fork). the wait) and exec/) families of calls, and exit) 2.2 Parsing the command line When parsing the command line, mysh should ignore all whitespace. You might find the isspace and strtok man pages useful. Please keep in mind that your commandline parser should work, but we do not expect it to be particularly fancy For example, and should not be treated specially by the parser. We'd much rather see you spend a lot of effort on the job control features of your shell. 2.3 Built-in commands Mysh should support the following built-in commands. jobs: Print a list of commands that are currently running or suspended. This list should include an integer, the command line that started the respective program and the status (Running or Suspended) of the program, e.g. mysh jobs [1 Running [2 Running [3 Suspended [4 Suspended xemacs projectl.tex xdvi projectl vi firefox kill%job: Sends a SIGTERM signal to the specified job, e.g. mysh# kill $2 would terminate the xdvi program from the previous example. fg %job: Continue executing the specified command in the foreground, e.g. mysh fg 3 would bring the vi program to the foreground. The shell would then wait for the user to either terminate the vi program or to suspend it using Control-Z. bg %job: Put the specified job in the background, continuing it if it was suspended, e.g. if a user
had started the firefox web browser, and suspended it using Control-Z, then mysh# bg $4 should let the browser continue running in the background. pwd: Print the current working directory. cd path: Change the current working directory to specified path. 3 Hints and Tips The man pages are your friends! Manpages of particular interest would be: fork) exit exec(), еxecl(), execv(), execle(), execve(), еxecip(), execvp() wait), waitpid) kill0 isspace(), strtok() This project should be developed on a UNIX OS. You are free to use any flavor of UNIX you want for development It should contain at least three parts: 1) an introduction to the basic structure of your shell; 2) a list of which features are fully implemented, partially implemented, and not implemented; and 3) a discussion of how you tested your shell for correctness.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>

int main( void ) {

    char *argv[] ={"",NULL};
    char comm[100];
    int p_pid;

    while(1)
    {
        printf("mysh#");
        scanf("%s",comm);
        p_pid = fork();

        if(p_pid > 0) {
            wait(NULL);
        }
        else if ( p_pid == 0 ) {
         execvp(comm,argv);
        }

    }

    return 0;
}


mysh #ls alaram.c fork_check.c fork_check.c fork_vfs.c fork_vfs.c just.txt shell.c sig_handler.c alaram.o a.out mysh#pwd |/ho

Add a comment
Know the answer?
Add Answer to:
Project 1: Implementing a Shell 1 Overview In this individual project you will have to design...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Overview Writing in the C language, implement a very basic shell, called smash. In this project,...

    Overview Writing in the C language, implement a very basic shell, called smash. In this project, we will work on processing strings and using the appropriate system calls. Build System setup Before we can start writing code we need to get our build system all setup. This will involve writing a very simple makefile. You should leverage your Makefile project for this part of the assignment! Write a Makefile that provides the three targets listed below all - The default...

  • You are currently running/debugging a shell script program in the foreground that seems to be in an infinite loop, to terminate/kill the shell script program. 7. (type/enter - control C to send a &#3...

    You are currently running/debugging a shell script program in the foreground that seems to be in an infinite loop, to terminate/kill the shell script program. 7. (type/enter - control C to send a "program interrupt" ) or (contact the sysadmin person to kill your shell script program) 8. The UNIX/Linux exit command entered on the KORN shell command line will exit the shell session properly (best practice). [True / False] When killing a background process with the kill command you...

  • Creating a Shell Interface Using Java This project consists of modifying a Java program so that...

    Creating a Shell Interface Using Java This project consists of modifying a Java program so that it serves as a shell interface that accepts user commands and then executes each command in a separate process external to the Java virtual machine. Overview A shell interface provides the user with a prompt, after which the user enters the next command. The example below illustrates the prompt jsh> and the user’s next command: cat Prog.java. This command displays the file Prog.java on...

  • Update the program in the bottom using C++ to fit the requirements specified in the assignment....

    Update the program in the bottom using C++ to fit the requirements specified in the assignment. Description For this assignment, you will be writing a single program that enters a loop in which each iteration prompts the user for two, single-line inputs. If the text of either one of the inputs is “quit”, the program should immediately exit. If “quit” is not found, each of these lines of input will be treated as a command line to be executed. These...

  • Using Unix processes Submit a README file that lists the files you have submitted along with...

    Using Unix processes Submit a README file that lists the files you have submitted along with a one sentence explanation. Call it Prj1README. MakeCopy.c : Write a C program that makes a new copy of an existing file using system calls for file manipulation. The names of the two files and copy block sizes are to be specified as command line arguments. Open the source file in read only mode and destination file in read/write mode. ForkCopy.c : Write a...

  • Project Description In this project, you will be developing a multithreaded Web server and a simple...

    Project Description In this project, you will be developing a multithreaded Web server and a simple web client. The Web server and Web client communicate using a text-based protocol called HTTP (Hypertext Transfer Protocol). Requirements for the Web server The server is able to handle multiple requests concurrently. This means the implementation is multithreaded. In the main thread, the server listens to a specified port, e.g., 8080. Upon receiving an HTTP request, the server sets up a TCP connection to...

  • Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQ...

    Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...

  • Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQ...

    Infix Expression Evaluator For this project, write a C program that will evaluate an infix expression. The algorithm REQUIRED for this program will use two stacks, an operator stack and a value stack. Both stacks MUST be implemented using a linked list. For this program, you are to write functions for the linked list stacks with the following names: int isEmpty (stack); void push (stack, data); data top (stack); void pop (stack); // return TRUE if the stack has no...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT