CST8204 - Lab 12
exec()- replace the current process
Your input and output programs from a previous lab and your fork/wait program both copied a text input file to an output file, something that cat(1) or cp(1) can do quite readily.
Write a program using exec(3) to invoke the cp standard utility to copy the input file named in argv[1] to the output file in argv[2]. Before the copy, print the name of the input file on stdout and after the copy is complete, print the name of the output file. Naturally, if an error occurs (check the cp return value to make sure it's 0), print an error message instead. There is no need to support the many variations of cp or any of its options.
For example, it might look something like:
System Prompt> ./inlab8 my.input my.output
Ready to copy my.input
Copy to my.output successful
System Prompt>
Plan to do the twice if you have time, once with the list form of exec(3) and once with the vector form. Be sure to check argc and to fix up argv (or a copy of it) if required, plus any other error checking that seems necessary (but hint: cp is perfectly capable of reporting missing files).