This is a beginner Linux class. I am just struggling with this assignment here. To receive the Fg the shell script must work and complete all the tasks below!
Whoever posts here first with the correct information will get the fg.
Scenario: You are the system administrator for a Unix/Linux system. Your users are primarily basic users. As you know, the ‘cp’ command allows you to copy multiple files to a single directory, such as:
cp abc xyz file1 file2 /tmp
This example command will copy the files abc, xyz, file1, file2 to the /tmp directory. Users on your system want the ability to copy a single file or directory to multiple locations. You need to write a script to accomplish this action because the ‘cp’ command does not allow you to do this. The command shell you will write looks like:
copyall file /tmp /usr/local/tst /home/test/1
Note that the above is just an example; you should not code the shell script with these exact parameters. In this example, the file ‘file’ will be copied to the directories /tmp, /usr/local/tst, and /home/test/1. Thus, a single file may be copied to multiple destinations. The output of this shell script should look like the following:
copyall: File file was copied to /tmp /usr/local/tst /home/test/1 on Wed Nov 9 23:07:08 CST 2011 by george123
In addition, the above line should be added (appended) to the file /tmp/copyall.
You should use the date and time that the copy was attempted; the above is just an example. The ‘george123’ should be replaced by the user running the command.
The specifics of the shell script are noted below:
1. The shell script must run as either a ksh or bash shell script; no other scripting languages are allowed.
2. If no parameters are given to the ‘copyall’ then the shell must print/echo a usage message explaining what is required to execute the shell
3. The first parameter of the shell script must be a file and it must exist. It must also be readable. If it is not, the shell script should exit with a status of 99.
4. If the shell script executed correctly it should exit with a status of ‘0’.
5. Under no circumstances should the file /tmp/copyall be overwritten; you add information to the file at the end.
6. Use the ‘echo’ command rather than the built-in ‘print’ command.
7. Put a series of comments at the top of the shell script indicating who wrote the shell script and the date it was written. Put a series of comments explaining what the shell script is supposed to do. Therefore, you name must be in the shell script itself.
8. All parameters after the first one must be directory targets, must be writable, and must exist. If any targets fail these checks print an appropriate error message and exit with a status of 99.
9. For full credit, when the shell script is run it must not produce any warning or error messages from the script interpreter.
10. Partial credit will be given based on how much the shell script does what was required. If nothing is turned in then no credit will be given.
11. The shell script is not designed to be interactive; do not ask the user for any information.
12. Make sure the permissions on your shell file are set so that they are private to you.
13. Make no assumptions about the number of targets; you need at least one but there can be any number of targets to copy the file to.
This post was edited by Biased on Apr 17 2017 07:03pm