ANTON
|
2009-06-28 05:30:18, Á¶È¸ : 159, Ãßõ : 49 |
f01:/home/Cron/Search# cat Scaner.pl
#!/usr/bin/perl
use strict;
use eFolder::Database;
use eFolder::CONFIG;
use strict;
sub ListDirectory{
my ($strTargetPath, $strUserName, $strPrefix) = @_;
my @arrStat = ();
my @arrDirectory = ();
my $nResult = opendir hDIR, $strTargetPath;
if($nResult == 0){
print STDERR "ListDirectory $strTargetPath : ". $!. "\n";
return 0;
}
while(my $strFileName = readdir(hDIR)){
my $strPath = $strTargetPath . "/". $strFileName;
if($strFileName ne "." && $strFileName ne ".."){
#print STDERR $strPath, "\n";
if( -d $strPath){
if(! (-l $strPath)) {
push(@arrDirectory, $strTargetPath."/".$strFileName);
}
}else{
@arrStat = stat($strPath) ;
$strPath =~ s/$strPrefix//;
$strPath =~ s/,/\\,/g;
$strFileName =~ s/,/\\,/g;
print $strPath. "," . $strFileName, "," . $arrStat[7] . "," .$strUserName. "\n";
}
}
}
closedir(hDIR);
while(my $strPath = pop(@arrDirectory)){
ListDirectory($strPath, $strUserName, $strPrefix);
}
}
my $db = new Database(&CONFIG::AccountDatabaseAddress);
my $query = "SELECT username_col FROM account_tbl WHERE sharetype_col = 1";
#print STDERR $query, "\n";
unless($db->Sql($query)){
print STDERR "Main::Cannot Read UserList from Database\n";
exit 1;
}
while($db->FetchRow()){
my $strUserName = $db->Data("username_col");
my @foo = getpwnam($strUserName);
my $strPath = $foo[7];
#print STDERR $strPath, "\n";
if ($strPath =~ /Public/) {
ListDirectory($strPath, $strUserName, $strPath);
} else {
print STDERR "WARNING: $strUserName 's home dir is not Public!\n";
}
}
|
|
|