Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Checking permissions on server

by wirrwarr (Monk)
on Jul 30, 2003 at 13:49 UTC ( [id://279178]=note: print w/replies, xml ) Need Help??


in reply to Checking permissions on server

The line "if ($_ ! -w)" is wrong.
It should be "if (! -w $_)".
And you forgot to close the string 'webdir/pathhere
The following script works on my system:
use strict; 
use File::Find; 
my $dir = '/webdir/pathhere';
find(\&ReadPerm, $dir); 
sub ReadPerm { 
  if (! -w $_) { 
    print "$File::Find::name\n"; 
  }
}

Replies are listed 'Best First'.
Re: Re: Checking permissions on server
by Anonymous Monk on Jul 30, 2003 at 14:15 UTC
    Thanks, this will let me know if I cant write AND/OR read any file or directory?
    use strict; use File::Find; my $dir = '/webdir/pathhere'; find(\&ReadPerm, $dir); sub ReadPerm { if (! -w $_) { print "$File::Find::name\n"; } }

      If you want to find out both read and write, then you'll need to do 2 tests: one for read, one for write. Simply do a test with '-r' as well, such as the following (not tested, may/may not work as-is):

      #!/usr/bin/perl -w $|++; use strict; use File::Find; my $dir = '/path/to/dir'; find(\&wanted, '/path/to/dir'); sub wanted { if (not -w $_ && not -r $_) { print "Cannot read or write $File::Find::name.\n"; } elsif (not -w) { print "Cannot write $File::Find::name.\n"; } elsif (not -r) { print "Cannot read $File::Find::name.\n"; } }


      If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://279178]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-20 03:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found