> -----Original Message-----
> From: Altrock, Jens [mailto:[EMAIL PROTECTED] 
> Sent: 12 January 2004 12:28
> To: Brian Raven
> Cc: [EMAIL PROTECTED]
> Subject: AW: Script for reading permissions on win32 - Try 
> Win32::FileSecu rity
> 
> 
> > -----Urspr�ngliche Nachricht-----
> > Von: Brian Raven [mailto:[EMAIL PROTECTED]
> > Gesendet: Donnerstag, 8. Januar 2004 13:33
> > An: [EMAIL PROTECTED]
> > Betreff: RE: Script for reading permissions on win32 - Try
> > Win32::FileSecu rity
> > 
> > 
> > > -----Original Message-----
> > > From: Altrock, Jens [mailto:[EMAIL PROTECTED] 
> > > Sent: 08 January 2004 10:38
> > > To: [EMAIL PROTECTED]
> > > Subject: AW: Script for reading permissions on win32 - Try 
> > > Win32::FileSecu rity
> > 
> > > Ok. I got it the way example1 says, and it works. The only 
> > > thing I don't
> > > know how to do is
> > > to get all the directories in one directory and get their 
> > > permissions...
> > > 
> > > Current source:
> > > 
> > >   use Win32::FileSecurity qw(Get EnumerateRights);
> > >   sub Laufen {
> > >   foreach (@ARGV){
> > >           if(Get($_, \%hash)){
> > >                   while(($name, $mask) = each %hash){
> > >                           print "$name:\n\t";
> > >                           EnumerateRights($mask,[EMAIL PROTECTED]);
> > >                           print join ("\n\t",@happy),"\n";
> > >                   }
> > >           }
> > >           else {
> > >                   print("Error #",int($!),": $!");
> > >           }
> > >   }
> > >   } 
> > >   Laufen($StartDir);
> > > 
> > > Anyone knows how to implement that in this source?
> > 
> > I believe that your original post mentioned recursion, so you should
> > probably look at File::Find. For example this little script does
> > something like what you ask:
> > 
> > --------------------------------------------------------------
> > ----------
> > ---------------------
> > use strict;
> > use warnings;
> > 
> > use Win32::FileSecurity qw(Get EnumerateRights);
> > use File::Find;
> > 
> > find \&wanted, @ARGV;
> > 
> > sub wanted {
> >     return unless -d;
> >     my %dacl;
> >     Get $File::Find::name, \%dacl;
> >     foreach my $group (sort keys %dacl) {
> >     my @rights;
> >     EnumerateRights $dacl{$group}, [EMAIL PROTECTED];
> >     print "$File::Find::name $group @rights\n";
> >     }
> > }
> > --------------------------------------------------------------
> > ----------
> > ---------------------
> > 
> > HTH
> > 
> > -- 
> > Brian Raven
> 
> So one more question I do have... 
> unless means he does it as long as there are any more 
> directories. correct
> me if I am not right at that
> point. So if I want to search only in the upper 3 directories from the
> starting directory maybe, I need
> to have a counter that goes down by one after each directory 
> right? Let's
> call this $i. Am I right to 
> decrease that number every time at the end of the 
> unless-block? and I need
> to check this in the unless-
> part like: return unless -d || $i>0;
> 
> so that would look like this:
> 
> sub wanted {
>       return unless -d || $i>0;
>       my %dacl;
>       Get $File::Find::name, \%dacl;
>       foreach my $group (sort keys %dacl) {
>               my @rights;
>               EnumerateRights $dacl{$group}, [EMAIL PROTECTED];
>               print OUT "Ordner:\t\t\t$File::Find::name\n";
>               print OUT "Benutzer/Gruppe:\t$group\nRechte:\t\t\t";
>               print OUT join ("\n\t\t\t",@rights),"\n\n";
>               print OUT
> ("---------------------------------------------------\n\n");
>       }
>       --$i;
> }
> 
> That was my thinking... as said correct me if i am not right 
> here. Problem
> is in the first directory he
> checks the files within too... and the search goes anyway through all
> directories... what's my error?

Not really.

"return unless -d;" effectively means return unless the entry is a directory, that is 
only process directories.

Also your modification will only show info about the first 3 directories found. If you 
want to limit the depth of search it might be easier to install File::Find::Rule, 
which is a wrapper around the standard File::Find module, then you could do something 
like:

use strict;
use warnings;

use File::Find::Rule;

my @dirs = File::Find::Rule->directory->maxdepth(3)->in(@ARGV);

foreach my $dir (@dirs) {
    ...

HTH

-- 
Brian Raven


-----------------------------------------------------------------------
The information contained in this e-mail is confidential and solely 
for the intended addressee(s). Unauthorised reproduction, disclosure, 
modification, and/or distribution of this email may be unlawful. If you 
have received this email in error, please notify the sender immediately 
and delete it from your system. The views expressed in this message 
do not necessarily reflect those of LIFFE Holdings Plc or any of its subsidiary 
companies.
-----------------------------------------------------------------------


_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to