Question: Write a program that mimics the shell by printing a SHELL> prompt, repeatedly, to allow the user to enter UNIX commands. (The commands you enter

 Write a program that mimics the shell by printing a SHELL>

Write a program that mimics the shell by printing a SHELL> prompt, repeatedly, to allow the user to enter UNIX commands. (The commands you enter should not use wildcards or other metacharacters). The entered command line should be executed with an appropriate exec call. Your program should terminate when the user types in exit. Also try running your solution with some of the shell's internal commands like umask and observe the behavior. Useful Tips: use built in C string operations to get tokens (words) out of a string buffer and perform string comparisons strtok, strcmp fork child to run the exec command, check the child's status on return use WEXITSTATUS to get exit status of a child process

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!