Question: The function takes 3 parameters. void execute_output_to_other(char *cmd1, char *const argv1[], char *cmd2_with_argv2) Finally, we now implement the execute_output_to_other() function, which is called when the
![The function takes 3 parameters. void execute_output_to_other(char *cmd1, char *const argv1[],](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3a14c6cd2c_57166f3a14be2c8d.jpg)
The function takes 3 parameters. void execute_output_to_other(char *cmd1, char *const argv1[], char *cmd2_with_argv2)
Finally, we now implement the execute_output_to_other() function, which is called when the user answers Yes to the "Should the output be re-directed to another command? [Y/N]" question. This has to be done with popen() and pclose(). Here are interactions with the command executor: > Enter a command you want to run: /bin/ls -la > Should the output be re-directed to a file? [Y/N]N > Should the output be re-directed to another command? [Y/N]Y > Enter that other command: /usr/bin/wc -1 ** Command successful ** The above command succeeds, and prints the number of lines in the output of 1s -la (which happens to be 11 when I ran it). For this question, we won't test error behavior. In other words, we'll only test your code with known-to-besuccessful commands combinations. My own solution for this question consists of 26 lines of code, including error checking. Hint: It will be very difficult to do this without using the dup() system call, which we discussed in class in the context of output redirection
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
