Answered step by step
Verified Expert Solution
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 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 execxl) 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 -1 ls -l | wc -1 > numfiles.txt ps -e --forest ps -ef > process_info.txt
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started