Link to home
Start Free TrialLog in
Avatar of rigsby
rigsby

asked on

File Permissions

I am running Perl on an AIX box and have written a script that automatically  creates a file should the file be removed / deleted etc.  However when the file is created it inherits only the read / write permissions of the user who ran the script at that time.

Is there any way I can overide this and set global permissions to this file as everyone uses the script?????
Avatar of maneshr
maneshr

sure you can do that.

you can embed the following command in you PERL script right after you have closed the file

$yourfile="/tmp/file.txt";

open(FILE,">file.txt") || die $!;

###Do some file write...

close(FILE);

`chmod 775 $yourfile`;
If you want to avoid launching an external process you can use the perl command "chmod" like so:

chmod(0775,"$yourfile1","yourfile2");
ASKER CERTIFIED SOLUTION
Avatar of amitpagarwal
amitpagarwal
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozo
see also: umask