Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1- Build a Shell that can execute a Unix Command Step 1- Modify the convertToC You will be using execv that requires a char**

Part 1- Build a Shell that can execute a Unix Command

Step 1- Modify the convertToC

You will be using execv that requires a char** as an argument. The catch is that the char ** has to be NULL terminated

Please do the following

1) allocate an extra "word" for NULL (Hint: tokenCount+1)

2) store the value of NULL into the extra "word"

Step 2- Modify the processCommand

You will be emulating a shell. First, the shell checks for specific commands ("shutdown", "lo", etc). If it does not recognize those commands then, a fork occurs and the child will execute the command as typed.

The algorithm to implement is as follows (Hint: add code inside the else):

1) fork to create a child and parent

2) the child will do the following:

Call the converToC function and capture the return into a char** variable

Call execvp sending it two arguments: the first element (or word) of the char** variable, and the entire array

Print an error message

exit

3) the parent will do the following:

wait for the child

return 1

4) don't forget to handle the error case of the fork

******************************************************************************************************

code is below...

******************************************************************************************************

image text in transcribed

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

Recommended Textbook for

Advanced Oracle Solaris 11 System Administration

Authors: Bill Calkins

1st Edition

0133007170, 9780133007176

More Books

Students also viewed these Databases questions

Question

int [ ] intArray = nee int [ 9 ] for ( int i = 0 ; i

Answered: 1 week ago