Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The purpose of this assignment is to test your understanding of basic process manipulation in C. You are required to write a C program called

The purpose of this assignment is to test your understanding of basic process manipulation in C. You are required to write a C program called myshell.c that performs some of the functions of a shell command line interpreter for the Linux operating system. The program should prompt the user with: [Enter command]> Your program should execute whatever programs are specified by the user's command, and once complete, it should again prompt the user. Continue prompting the user until he/she types exit". When the user types in a line, your program should parse the command line to determine what program to run, and also to determine the sequence of parameters that should be sent to the program. The program that a user wishes to run may not be in the current directory; thus, it may be necessary to search for it elsewhere. You should search the directories specified in the PATH environment variable for the program that the user wants to execute. Use the getenv() function to determine the contents of the PATH environment variable, and the stat() function to determine if a file exists. If the file is found, then it should be executed with any parameters that the user may have specified. Use an execv() system call to execute the file that contains the command. In addition to executing simple commands with parameters, your program should also be able to perform output redirection and piping. The user will specify output redirection by placing the character > following the program (and parameters) to be executed and placing the name of the file to which output will be redirected following the >. The user will specify that a pipe should be created between two programs by inserting the character | in between the two programs to be executed. Here are some examples of commands that your program should be able to deal with.

ls

ls -l

ls -l > file_list.txt

ls -l | wc -l

ls -l | wc -l > numfiles.txt

ps -e forest

ps -ef > process_info.txt

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

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago