1822034 Members
3452 Online
109639 Solutions
New Discussion юеВ

syslog scanning

 
hrishys
New Member

syslog scanning

Hi

I would like to scan the syslog file continously and page me the new line as and when a new line is added to the syslog file.Does anybody have a perl script for doing this ?

regards
Hrishy
3 REPLIES 3
Sergejs Svitnevs
Honored Contributor

Re: syslog scanning

You could use File::Tail (Perl extension for reading from continously updated files) for the tail -f.

http://search.cpan.org/search?query=File-tail&mode=all

Regards,
Sergejs
Vitaly Karasik_1
Honored Contributor

Re: syslog scanning

Tibor Bajnok
Occasional Advisor

Re: syslog scanning

Whithout any modul you can do the following:

open(LF, "tail -f $LOGFILE |") || die "no logfile !";
while () {
.
.
}


So you open the $LOGFILE with "tail -f", and
the "|" send it into a pipe.
Inside the "while" you can get the new lines
and work with them.