Search code examples
bashshellunixscriptingautosys

Change Owner of a script in unix


I have a unix shell script file whose owner is "xyz" when run deletes some specific files.

I want to trigger this script to delete files in some other directory where the owner for the files to be deleted is different from the owner of the script. Is this possible? Is this possible to run this script as different user so that it can delete those new files?

EDIT : I use Autosys to periodically trigger this script.


Solution

  • You can chmod the files that need to be deleted first if you have sufficient rights. Afterwards your script, no matter what user it executes, will succeed.

    Examples : http://en.wikipedia.org/wiki/Chmod