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?????
rigsbyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
amitpagarwalConnect With a Mentor Commented:
Here's how to change the permissions of fred and barney while checking the errors for each:

foreach $file ("fred","barney") {
  unless chmod (0777,$file) {
  warn "hmm... couldn't chmod file.$!";
  }
}
0
 
maneshrCommented:
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`;
0
 
guadalupeCommented:
If you want to avoid launching an external process you can use the perl command "chmod" like so:

chmod(0775,"$yourfile1","yourfile2");
0
 
ozoCommented:
see also: umask
0
All Courses

From novice to tech pro — start learning today.