Use perl to simulate tail command

上一篇 / 下一篇  2008-11-12 14:08:35 / 个人分类:Perl

$logfile = "installation.log";
$endOfFile = "Log_is_the_end_of_file";
$installfile = "interactivelyInstallPanINM.pl";

## Clean up log file
open CLEAN, "> $logfile"
     or die "Can't open the file: $logfile! ($!)";
close CLEAN;

## Call $installfile to write log into the log file
open FH, "interactivelyInstallPanINM.pl |" or die "fork: $!";

## Simulate the tail command.
open FILE, "< $logfile"
     or die "Can't open the file: $logfile! ($!)";

## read until end of file
while (1) {
    my $_ = <FILE>;
    if (/\b$endOfFile\b/){
      last;
    }else{
     print;
    }
}
## last will goto here
close FILE;
close FH;


TAG: Perl tail

 

评分:0

我来说两句

日历

« 2024-05-02  
   1234
567891011
12131415161718
19202122232425
262728293031 

数据统计

  • 访问量: 47911
  • 日志数: 80
  • 建立时间: 2008-10-27
  • 更新时间: 2009-07-17

RSS订阅

Open Toolbar