We execute script to tarr files as normal user. Normal user doesn't have permission to append file to existing tarr file, since tarr files are owned by root user.
Even though script is creating tar file and is executed by normal user, It shows that tar file is created by root. I ran script for the date range 13-SEP-2011 and 14-SEP-2011. File tarring listed all files for the date 13-SEP-2011 first and tarred it and listed all the files belongs to 14-SEP-2011 then it tried to append these files to existing tarr file since both dates belong to the same week.Since normal user did not has enough permission to change the permission of the tarr file. Hence error occurred.
Example: Say, there are three files present in test directory namely a.txt, b.txt, c.txt and all are owned by root and belons to different week.
tar cvf TarFilename a.txt --> Working as expected.
The above script creates tarr file which is owned by root. since tarr fie retains propreties of file got tarred.
chmod 777 TarFilename
tar -rf TarFilename b.txt --> Failing since normal user does not has the permission to change the permission of tarr file.
We have two options now.
- Change the owner of the directory where files need to be tarred.
- Change the owner of the files(a.txt,b.txt etc) before sending it to our database.
Is there any way that we can achive this apart from above cases. please let me know.
Please let me know if need any details.
Thanks and Regards
Nagaraja