Write a C program called chain3. It will do the following: 1. Prompt the user for an input file. You may assume the filename is
Write a C program called chain3. It will do the following:
1. Prompt the user for an input file. You may assume the filename is less than 1200 characters. It will ask by printing a prompt that says 'enter input file: '.
2. Prompt the user for a 1st command to run(as a single line of input). You may assume that the input line is less than 4000 characters. It will ask by printing a prompt that says 'enter first command: '.
3. Prompt the user for a 2nd command to run, as a single line of input. You may assume that the input line is less than 5000 characters. It will ask by printing a prompt that says 'enter second command: '.
4. Prompt the user for a 3rd command to run, as a single line of input. You may assume that the input line is less than 4000 characters. It will ask by printing a prompt that says 'enter third command: '.
5. Prompt the user for an output file. You may assume the filename is less than 1000 characters. It will ask by printing a prompt that says 'Please enter an output file: '.
6. It will then cause the 3 commands to be executed. The 1st command will get its input from the input file. The 1st commands output will be redirected to the input of the 2nd command. The 2nd commands output will be redirected to the input of the 3rd command. The 3rd commands output will go into the output file.
Other requirements:
The output file should be replaced, not appended to. You cannot use the system() function call. You must use an exec call to run the commands. The commands entered may have arguments. You need to break up the line entered into the command itself, plus the arguments. You may assume there are no more than 50 arguments for each command.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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