in reply to Re: Checking permissions on server
in thread Checking permissions on server

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"; } }

Replies are listed 'Best First'.
Re^3: Checking permissions on server
by Coruscate (Sexton) on Jul 30, 2003 at 21:46 UTC

    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.