Since you're doing a string compare on $groupname, you need to use 'ne', not
'!='.
<code>
foreach my $file (@files) {
#getgrpid returns the group file entry for a given group id.
my $groupname = (getgrgid((stat($file))[5]))[0];
if ($groupname ne "groupname") {
print "$file has bad groupname: $groupname\n";
}
}
</code>
(since "foo" == "bar" numerically)
> -----Original Message-----
> From: Chas Owens [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, June 27, 2001 3:11 AM
> To: [EMAIL PROTECTED]
> Subject: Re: checking groups on unix
>
>
>
> How to build @files is left as an exercise for the reader.
>
> <code>
> foreach my $file (@files) {
> #getgrpid returns the group file entry for a given group id.
> my $groupname = (getgrgid((stat($file))[5]))[0];
> if ($groupname != "groupname") {
> print "$file has bad groupname: $groupname\n";
> }
> }
> </code>
>
>
> On 27 Jun 2001 09:59:07 +0100, PURMONEN, Joni wrote:
> > Hi ya,
> >
> > I need to check the group status on numerous files/directories,
> and haven't
> > been able to fing out the best way to do it with perl. I simply
> need to see
> > if some directories do not have certain group set on them.
> >
> > Can anyone give any pointers?
> >
> > Cheers,
> >
> > Joni
> >
> > Ps. I only have learning perl and some other fairly simple books which
> > didn't seem to have anything useful in them
> >
> --
> Today is Pungenday, the 32nd day of Confusion in the YOLD 3167
> This statement is false.
>
>
>