?
Solved

perl tail log

Posted on 2009-12-22
3
Medium Priority
?
408 Views
Last Modified: 2012-05-08
while(1) {
my ($nfound,$timeleft,@pending)= File::Tail::select(undef,undef,undef,'60',$log);
unless ($nfound) {
  print nothing;
}

else {
  my $line = $log->read;
  print $line;
}

But I want to do someting like

tail the file
if nothing in the file then sleep for 1 min and then print nothing
if something in the file just print the message without sleeping please advise
0
Comment
Question by:saibsk
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 2000 total points
ID: 26110850
if( -z $log ){
  sleep 60;
}else{
   print $log->read;
}
0
 

Author Comment

by:saibsk
ID: 26111766
after sleep i need to tail the log file again to check if it has anything only then print nothing
0
 
LVL 85

Expert Comment

by:ozo
ID: 26123168
how does that differ from the original code?
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question