(Solved) : Round 1 Sequencec Program Read Execute List Commands Stdin Command Arguments Appear Separa Q37252643 . . .


Round 1: sequence.c This program should read and execute a list of commands from stdin. Each command and its arguments (if any) will appear on a separate line. For example, if the file “cmdfile” contains the lines: whoami cal 4 2019 echo The time is: date then running 1 /sequence< cmdfile should output your username, a calendar of the month of April, the string “The time is:”, and the current date/time, to standard output. Suggested approach: first, make sure you can parse a command and its arguments correctly, and store them as an array of C strings. Test this thoroughly before moving on, making use of trace statements to make sure you’ve accounted for all the cases you can come up with! Debugging processes and pipes can be tricky so you want to have confidence you are giving later parts of your program the correct input. For the purposes of this prac, you can assume a maximum of 10 arguments per command, 256 characters per line, and 100 lines per file. Second, look at the exec) family of functions and use one to execute each command in turn. Hint: there is a sample program from the first lecture on processes that does something very similar! Here is a pseudo-code version of the setup: 1 while there are remaining commands read line from file parse line into command and arguments 4 5 for cmd in commands 6 7 fork and handle errors if (child) else// parent 10 execute command wait for child to terminate 12 Show transcribed image text Round 1: sequence.c This program should read and execute a list of commands from stdin. Each command and its arguments (if any) will appear on a separate line. For example, if the file “cmdfile” contains the lines: whoami cal 4 2019 echo The time is: date then running 1 /sequence
Expert Answer
Answer to Round 1: sequence.c This program should read and execute a list of commands from stdin. Each command and its arguments (…
OR