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