⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 checkforholes.pl

📁 java日志读写
💻 PL
字号:

# This script checks for holes while rolling a log file.

$input=$ARGV[0];
$MAX_COUNT=$ARGV[1];
$LAST_EXPECTED=$ARGV[2];

$counter = 0;
$expected = 0;	

for($i = $MAX_COUNT; $i >= 1; $i--) {
  checkOrder("$input.$i");
}

checkOrder("$input");

if($expected == $LAST_EXPECTED) {
  print "All files as expected.\n";
}
else {
  print "Missing output or unexpected output in $input$i.\n";
  exit 1;
}


sub checkOrder {
  $file = $_[0];
  if(-e "$file") {
    $firstLine = `head -1 $file`;
    chomp $first;
    $lastLine = `tail -1 $file`;

    if($firstLine =~ /MSG $expected/) {
      print "First line of $file in expected order.\n";
    }
    else {
      print "First line of $file not as expected.\n";
      exit 1;
    }

    if($lastLine =~ /MSG (\d*)/) {
      $expected = $1 + 1;
    }
    else {
      print "last line of $file in unexpected format.\n";
      exit 1;
    }    
  } 
  else {
    print "Skipping inexistent file [$file].\n";
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -