Hello all,
I have a few questions regarding a UNIX script I've been asked to write (even though I barely know UNIX!).
I would like to write a script, that when run, will copy a file from one directory to another, copy and rename the same file with a datestamp to an archive directory, and them delete the file from the current directory.
This is what I came up with and was hoping the experts here could throw in their 2 cents. (I'm assuming this works, as I'm still waiting on getting access to the server as well as getting the SSH Tectia Client installed on my workstation):
approve.sh - (name I plan on giving the script)
#PATH variable should include /bin directory ???
#script can then be executed by typing "sh approve filename"
#
#Step 1 - Copy to Prod
#
echo "Copying file $1 to Production Directory"
cp [-fip] $1 $1 /prod/appfolder
#
#Step 2 - Copy to Archive
#
echo "Archiving file $1 to Archive Directory"
DAY=`date +%d`
MONTH=`date +%b`
YEAR=`date +%Y`
cp $1 $1.$MONTH.$DAY.YEAR /archive/unknownfoldername
#
#Step 3 - Delete file (might be able to do this in step 2 with a move)
#
echo "Deleting file $1 from Temporary Directoty"
rm $1
exit 0
Does that look like something that will work? What concerns should I have when it comes to the authority to run the script? Will the person authorized to run the script need read authority to the file? I would like the "approver" who runs this script to have only read access to the file.
As you can tell I'm pretty new to this, so any help would be GREATLY appreciated!
Thanks!