Skip to content

Instantly share code, notes, and snippets.

@eskatos
Created June 25, 2012 15:12
Show Gist options
  • Save eskatos/2989199 to your computer and use it in GitHub Desktop.
Save eskatos/2989199 to your computer and use it in GitHub Desktop.
cgi tail
#!/usr/bin/perl
use CGI;
use File::Tail;
print "Content-type: text/html\n\n";
$| = 1; #set auto flush on
# hardcode filename
$file_name = "/path/to/file";
# show 100 lines by default
$tail_lines=100;
$tail_file=File::Tail->new(name=>$file_name,
maxinterval=>30,
adjustafter=>5,
maxbuf=>16384,
tail=>$tail_lines);
while (defined($readline=$tail_file->read))
{
print $readline."</br>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment