Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1517399
  • 博文数量: 289
  • 博客积分: 11086
  • 博客等级: 上将
  • 技术积分: 3291
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-22 17:06
个人简介

徐小玉的博客。

文章分类

全部博文(289)

文章存档

2023年(6)

2022年(1)

2021年(2)

2020年(9)

2019年(9)

2018年(6)

2017年(10)

2016年(10)

2014年(3)

2013年(4)

2011年(12)

2010年(16)

2009年(14)

2008年(119)

2007年(48)

2006年(20)

我的朋友

分类:

2008-02-29 14:43:36

#!/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);
阅读(1321) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~