Hello everyone, my name's Chris; I'm a newbie obviously
I'm writing a shell script that must copy a single file (sampletext) to multiple directories (folder1, folder2) ; my normal linux go to guy hasn't replied to an email for a while...
So far what i've done -- I created a directory to keep my scripts in, 2 directories I want my file to be copied to, and the file to be copied in a 3rd directory.
The parameters for the script are as follows:
1. The shell script must run as either a ksh or bash shell script.
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.
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. When the shell script is run it must not produce any warning or error messages from the script interpreter.
11. The shell script is not designed to be interactive; do not ask the user for any information.
so i have: /home/text-file/sampletext <----the file to be copied
to /home/folder1 and to /home/folder2
Here's what I have so far:
#!/usr/bin/ksh
# This copy script was written by Joe Schmoe on November 5, 2013.
# This script's purpose is to copy single files to multiple directories.
for file in /home/a0699761/text-file/sampletext
do
cp sampletext ${path} ${path}
done
exit0
Thanks for any help, I've only been using linux for 2 months :-/