Chat with us, powered by LiveChat Write a C program, mysh, which simulates the Unix sh for command processing. | WriteDemy

Question Description

the class website page:

https://www.eecs.wsu.edu/~cs360/LABsh.html

refer to note#3: process management and programming assignment #3 for more information.

 Write a C program, mysh, which simulates the Unix sh for command processing.   Your mysh should run as follows:------------- PART 1: Single Command with I/O Redirection ---------------1. Prompt for an input line, which is of the form          cmd arg1 arg2 arg3 .... argn    where cmd is a command.   Valid commands include "cd", "exit", and ANY Unix binary executables,    e.g. echo, ls, date, pwd, cat, cp, mv, cc ... you name it !!!2. Handle simple commands:     cmd = "cd"   :  chdir(arg1) OR chdir($HOME) if no arg1;     cmd = "exit" :  exit(1) to terminate;     NOTE: chdir(pathname) is a syscall to change CWD.         $HOME is the home directory; YOU must find its value from *env[ ].3. For all other commands:      fork a child process;      wait for the child to terminate;      print child's exit status code      continue step 1;4. Child process: First, assume NO pipe in command line:   4-1. Handle I/O redirection:          cmd  arg1 arg2 ...  <  infile    // take inputs from infile          cmd  arg1 arg2 ...  >  outfile   // send outputs to outfile          cmd  arg1 arg2 ...  >> outfile   // APPEND outputs to outfile   4-2. Execute cmd by execve(), passing parameters                 char *myargv[], char *env[]        to the cmd file,         where myargv[ ] is an array of char * with              myargv[0]->cmd,               myargv[1]->arg1, .....,               Ending with NULL pointer   4-2. NOTE: your myargv[] must be passed correctly, as in              cmd one two three        Then in the cmd program, argc=4, myargv[0]="cmd", myargv[1]="one", etc.------------------ PART 2: Commands with Pipes ---------------------------5. After YOUR mysh works for simple commands, extend it to handle PIPE.   If the command line has a | symbol:          divide it into head and tail: e.g.          cmd1 < infile | cmd 2 > outfile      head = "cmd < infile";   tail = "cmd 2 > outfile"   Then consult the pipe example code in the class notes to see HOW TO         create a pipe        fork a child process to share the pipe        arrange one process as the pipe writer, and          the other process as the pipe reader.        Then, let each process execve() to its command              (possibly with I/O redirection). 6. ===================== BONUS ====================   If YOUR mysh can handle MULTIPLE pipes like           cat file | grep "test" | more           cat fle  | cat | grep "test" | more   etc.   ===============================================7. For sh scripts files:(1). Run command as  "bash filename"  OR(2). Assume the first line of every sh script begin with            #! /usr/bin/bash     open the file for READ;       read 256 chars from file beginning to a char buf[256];     close the opened file     strncmp(buf, "#!", 2) to check whether the first 2 chars are #!;     if so, cmd = "/usr/bin/bash", myargv[0]="bash", argv[1]="filename";     Then execve(cmd, myargv, env);8. SAMPLE SOLUTION:      ~samples/LAB3/lab3.bin          (down load and run under Linux)           OR    ~samples/LAB3/lab3.static.bin   (statically linked binay executable) 

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Place Order” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order