#!/usr/bin/perl -w
use strict;
use IO::Socket;
my $chkname ;
my $chkline ;
my $chksize ;
system(`rm -f chekerr.log`);
open SOU," < chk.log"; #打开文件。
open LOGFILE," >> /odfs01/oddev3/proc_xd/myl/perl/data/chekerr.log";#打开记录处理日志的文件
my $a = localtime(time);
print LOGFILE "the start time is : $a\n";#得到系统时间
foreach()
{
open FILE ,"< $_";
my $file = $_;
chomp($file);
my @totalsize=stat(FILE);
my $size=$totalsize[7];
chomp($size); # 得到文件大小
my $len =` head -n 1 $file |awk '{print length(\$0)}' `;
my $length = $len + 1;
my $line = $size / $length; # 得到文件长度
# 读校验文件,获得在生产机上的该文件大小与长度。
open CHKFILE ,"$file.chk" ; #打开校验文件句柄
foreach()
{
my $chkfile=$_;
# print "chkfile is : $chkfile \n";
my @chkarray=split(/,/,$chkfile);
my $chkname = $chkarray[0];
my $chkline = $chkarray[1];
my $chksize = $chkarray[2]; # 得到文件对应的校验文件的大小,行数等。
if ($line==$chkline && $size==$chksize)
{
}
elsif($line!=$chkline)
{
print LOGFILE "ERROR !! , file $chkname 's line is $line ,line in $chkname.chk is $chkline \n";
# print "ERROR!! the error file is : $chkname,there are some wrong here ,please check the data!\n";
}
elsif($size!=$chksize)
{
print LOGFILE "ERROR !! , file $chkname 's size is $size ,size in $chkname.chk is $chkname \n";
}
}
}
my $b = localtime(time);
print LOGFILE "the end time is : $b\n"; # 得到结束时间
close(LOGFILE);
close(CHKFILE);
阅读(1361) | 评论(0) | 转发(0) |