Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

shell. c below is a stripped down shell program. It will run a Unix command without , any arguments. Copy and save the program as

image text in transcribedimage text in transcribed

shell. c below is a stripped down shell program. It will run a Unix command without , any arguments. Copy and save the program as shell.c. Modify the program so that it can execute any shell command. It should be able to take at least 2 arguments. Usually, you need to parse the cornmand line you enter. Using execvp instead of execlp will probably help. It should work on any UNIX command consisting of 0-2 arguments after the command entered by the user, and be error free. The following are a few test cases that the user could enter. $ cp file1 file2 $ Is - $ who char *strtok (char *str , const char *delim) is a useful function for parsing the input string. You can see below how it used " " as a delimiter to get everything before that character. You can specify " " as a deliniter to split the string into arguments. The first time you use it, give it a string as the first parameter to tokenize. This will return the first token. You can then use it subsequent times with NULL as the first parameter and it will return subsequent tokens in order. After the last token was returned, it returns NULL. For example if you wrote: char nput [] "Hello World !": strt ok (in put , " "} strtok (NULL . "" strtok (NULL . "" the first call would return "Hello ". The second call would return "World !". And the third call would return NULL

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

Beginning VB.NET Databases

Authors: Thearon Willis

1st Edition

1594864217, 978-1594864216

More Books

Students also viewed these Databases questions

Question

How can user view performance model of KNN model?

Answered: 1 week ago

Question

=+What is the nature of the plant or site-level role of unions?

Answered: 1 week ago