"Troll" <ab***@microsoft.com> wrote in message
news:MD********************@news-server.bigpond.net.au...
Hi,
Would something like:
if (-r $name) {
: # do nothing
} else {
print "File is not readable...\n";
}
be enough to test if a file is readable by all users?
I'm a little unsure which bit does the -r relate to.
What about if I wanted to test whether the file is readable by the owner's
group but not everyone else?
Cheers
I had a look at stat and can read the permissions. But what I need to do
then is change the file permissions ONLY if the file is not readable by all
users.
Should I be trying to capture the output of:
$mode = (stat "test.txt") [2];
printf "%0\n", $mode & 07777; # this gives me the original permissions
and then sed-ing it so as to read the last character? If the last char > 3
then the file is readable by all users.
How can I assign the above printf output to a scalar?
Any pointers welcome :)