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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
amitpagarwalCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ozoCommented:
see also: umask
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.