For one case...

my file:
quote:
DOS : 5.0
Specific OS : Windows 2000 Professional
OS Suite : 0
OS Small Business : 0
OS Enterprise : 0
OS BackOffice : 0
OS CommServer : 0
OS Terminal Server : 0
OS Small Business : 0
OS Embedded NT : 0
OS DataCenter : 0
OS Single User TS : 0
OS Home Edition : 0
OS Blade Server : 0
Admin Rights : 1
SMS Client : 0
System Date : 2003/09/05
User Language : 0804Chinese
System Language : 0804Chinese
Rpcrt4.dll Version : 5.00.2195.6753
Working IP Address : 202.0.212.184
Working Subnet Mask : 255.255.255.0
Working Gateway : 202.0.212.1
Subnet : 202.0.212.0
Working MAC Address : B42320524153
Host Name : temp-pc
Domain : FAI-xxx
Windows 2000 Site :
RAS Sessions : 0
VPN Session : 0
User : aa099672
Full Name : xxxx, Larry
Logon Server : \\CN2SDB1
Logon Domain : AMPx1
Computer Name : TEMP-PC
CSD : Service Pack 4
MS03-026 : 1
Cleaned : 0
SysRestore Stop :
SysRestore disabled :

code:
use File::stat;
use strict;

#my $ReportFile = "h:\\EPO-Report.txt";
my $ReportFile = "c:\\data\\scripts\\bug-Report.txt";
unlink $ReportFile;

my $fileCount=0;

foreach my $dir ("\\\\ambdc009\\log\$\\nachi","\\\\ambdc009\\log\$\\nachicleaned")
{
my $i=1;
$fileCount++;
opendir (F, $dir) || "Could not open directory: $dir\n";
my @filelist = readdir(F);
closedir (F);
my $date_string;

File: foreach my $file (@filelist)
{
my (@data,@data2,$field, $value,$computer);
next File if $file eq "." or $file eq ".." ;
if ($file =~ /(.*)\.txt/ and -e "$dir\\$file")
{

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(stat("$dir\\$file")->mtime);
$year += 1900;
$mon += 1;
$date_string = sprintf( "%04d/%02d/%02d %02d:%02d:%02d", $year, $mon, $mday, $hour, $min, $sec);
push @data, ["LogonTime(GMT -4)", $date_string];

open (F, "<$dir\\$file");
while(<F>)
{
chomp;
($field, $value) = $_ =~ /^(\w[\w\s\.\-]+\w)\s+\:([\s\w\.].*?)$/;
next if $field eq "";
$value =~ s/^\s+//;
push @data, [$field, $value];
}
close F;
}
$field = "";
$value = "";
if (scalar(@data) < 34)
{
print "\n$file\n";
next;
}
if ($i==1 and $fileCount ==1)
{
map { push @data2, $$_[0]} @data;
$data2[9] = 'OS Small Business (Restricted)';
$field = join("~", @data2);
&Log($field);
}

@data2 = ();
map { push @data2, $$_[1]} @data;
$value = join("~", @data2);
print "\r$i of " . (scalar(@filelist)-2);
&Log($value);
#unlink "$dir\\$file";
$i++;
}
print "\n";
}

sub Log
{
my $text = shift;
open (R, ">>$ReportFile") || die "Could not open $ReportFile\n";
print R "$text\n";
close R;
}

_________________________
Home page: http://www.kixhelp.com/hb/