Question: PLEASE SOLVE THIS QUESTION WITHOUT USING ANY OTHER ANSWERS ALREADY ON CHEGG AND SO THAT THE OUPUT CLOSELY MATHCES THE SAMPLE OUTPUT OR ELSE DISLIKE!

PLEASE SOLVE THIS QUESTION WITHOUT USING ANY OTHER ANSWERS ALREADY ON CHEGG AND SO THAT THE OUPUT CLOSELY MATHCES THE SAMPLE OUTPUT OR ELSE DISLIKE! IF ALL IS GOOD WILL GIVE LIKE!! THANK YOU
Sample_input.txt:
pwd
ls -l -a -F
ps
pwd -L -P
ls
cat makefile
Sample_output.txt
The output of: pwd : is
>>>>>>>>>>>>>>>
/home/osc/eecs3221/a01
The output of: ls -l -a -F : is
>>>>>>>>>>>>>>>
total 40
drwxrwxr-x 2 osc osc 4096 May 1321:51./
drwxrwxr-x 3 osc osc 4096 May 1321:50../
-rwxrwxr-x 1 osc osc 17824 May 1321:50 Assignment_1*
-rw-rw-r--1 osc osc 153 May 1123:34 makefile
-rw-rw-r--1 osc osc 49 Feb 113:01 sample_in.txt
-rw-rw-r--1 osc osc 0 May 1321:51 sample_out.txt
-rw-rw-r--1 osc osc 2699 Jan 2919:32 sampleSol_a01.c
The output of: ps : is
>>>>>>>>>>>>>>>
PID TTY TIME CMD
1151 tty100:00:00 bash
1220 tty100:00:00 Assignment_1
1224 tty100:00:00 ps
The output of: pwd -L -P : is
>>>>>>>>>>>>>>>
/home/osc/eecs3221/a01
The output of: ls : is
>>>>>>>>>>>>>>>
Assignment_1
makefile
sample_in.txt
sample_out.txt
sampleSol_a01.c
The output of: cat makefile : is
>>>>>>>>>>>>>>>
# Do not edit the contents of this file.
warnings_BAD: *.c
gcc -Werror -Wall -g -std=gnu99-o Assignment_1*.c -lrt
clean: *.c
rm Assignment_1
Instructions:
In this assignment, you will have a parent process that will create children processes to perform tasks and
will collect the output from these children processes. There are three tasks that should be performed:
Read the input file that contains Linux shell commands. Parent process will read that.
Execute the Linux shell commands read from the input file and execute them one by one. A child
process will be created to execute these commands and the output will be returned by the child
process in the form of string using anonymous pipe.
The parent process will write the output of the command(s) to the screen using the given function.
The following flow chart describes the flow of the program.
Description
Write a C/C++ program that includes the code for following tasks. Write all the code in single file:
1. Write the parent program as per the description in the Synopsis. The parent program must use
fork system call to create children process(es) when required.
2. Read the sample input file, sample_in.txt. The name of the file must be given to the main/parent
process through command line arguments.
Parent
Process
fork() Child Process
Run
command
Write to pipe
pipe
Read from pipe
Write to screen using given
function, one by one
Read from file and write to dynamic array
Performed multiple times
a) This file contains one shell command per line.
b) Since the file is created in Windows environment, line terminator is \r
.
3. Store the commands in a dynamically allocated array.
4. Execute the commands one by one with the help of a child process:
a) Use a suitable version of exec system call to execute shell commands.
b) The child process must write the output of the command to an anonymous pipe but doesnt
display it to the screen. The parent process will read the command output from the pipe
and and will display it to the screen.
c) You may use only one child process by doing fork once to execute all the commands or
fork again and again.
d) The parent process must use the provided output function, writeOutput(), to write the
output to the screen. Invoke the output function iteratively, once for each command.
Warning: If you will not use this function to display the output then your outcome
will not match with our outcome, and you will be awarded zero.
5. The other implementation details are on your discretion, and you are free to explore.
6. In order to test your code, use the sample_in.txt and compare the output of your program for
this input file with the content of sample_out.txt. However, keep in mind that due to the nature
of the commands, the output is specific to the content of the directory in which you run your
program. Hence, verify the output of commands by running them directly on Linux shellIn this assignment, you will have a parent process that will create children processes to perform tasks and
will collect the output from these children processes. There are three tasks that should be performed:
Read the input file that contains Linux shell commands. Parent process will read that.
Execute the Linux shell commands read from the input file and execute them one by one. A child
process will be created to execute these commands and the output will be returned by the child
process in the form of string using anonymous pipe.
The parent process will write the output of the command(s) to the screen using the given function.
The following flow chart describes the flow of the program.
 PLEASE SOLVE THIS QUESTION WITHOUT USING ANY OTHER ANSWERS ALREADY ON

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!