Folks,
I used my linux box running perl 5.8 to develop a small script that
scans a list of directories and searches for files that dont have the group
set to "productn" or "dialup". It works great on my linux box, but now
I need to run it on our sun systems which are running perl version 5.005_02.
(Ungrading perl is not a solution unfortunatly, developers would freak out).
It doesnt seem to work at all on the sun systems. It never seems to
enter the directories and doesnt find anything.
A normal program run looks like this on my linux box...
[EMAIL PROTECTED] mcunning]$ ./scan-novell
Checking the directory: /nfs/links/live.run
Filename - GroupID (thats not productn or dialup)
-------------------------------------------------
/nfs/links/live.run - root
/nfs/links/live.run/passwd - root
/nfs/links/live.run/test4 - nut
Checking the directory: /nfs/links/prefixes
Filename - GroupID (thats not productn or dialup)
-------------------------------------------------
/nfs/links/prefixes - root
/nfs/links/prefixes/passwd - root
/nfs/links/prefixes/test3 - root
/nfs/links/prefixes/test4 - root
/nfs/links/prefixes/testsubdir - root
/nfs/links/prefixes/testsubdir/test6 - nut
Checking the directory: /nfs/links/transmit
Filename - GroupID (thats not productn or dialup)
-------------------------------------------------
/nfs/links/transmit - mcunning
A bad run on one of my sun systems looks like this..
mickey(mcunning)$ ./scan-novell
Checking the directory: /nfs/links/live.run
Filename - GroupID (thats not productn or dialup)
-------------------------------------------------
Checking the directory: /nfs/links/params
Filename - GroupID (thats not productn or dialup)
-------------------------------------------------
Checking the directory: /nfs/links/prefixes
Filename - GroupID (thats not productn or dialup)
-------------------------------------------------
Checking the directory: /nfs/links/storage
Filename - GroupID (thats not productn or dialup)
-------------------------------------------------
Checking the directory: /nfs/links/transmit
Filename - GroupID (thats not productn or dialup)
-------------------------------------------------
Can't call method "name" on an undefined value at ./scan-novell line 41.
Any ideas where I am going wrong?
The code is below..
Thanks for any help you can offer. Mike
--------------------------------------------------------------------------------------
#!/usr/bin/perl
# This program will scan the novell nfs mounts on a
# host, if each one exists, for permission problems.
# It will then list out the files that need to be
# fixed.
#
# MC - 9/10/03
use File::Find;
use File::stat;
use User::grent;
$basedir = "/nfs/links/";
@dirlist = qw(live.run params prefixes storage transmit);
*name = *File::Find::name;
foreach $directory (@dirlist) {
if ( -d "$basedir$directory"){
print "\n";
print "Checking the directory: $basedir$directory\n";
print "Filename - GroupID (thats not productn or dialup)\n";
print "-------------------------------------------------\n";
find(\&wanted, "$basedir$directory");
}
}
sub wanted {
my $check = stat($_);
return unless $check;
if ( -d $_ || -f $_ ) {
my $groupname = group($check->gid());
if ($groupname ne "productn" && $groupname ne "dialup"){
print "$File::Find::name - $groupname\n";
}
}
}
sub group {
my $gid = shift;
$group{$gid} = getgrgid($gid)->name || "#$gid"
unless defined $group{$gid};
return $group{$gid};
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]