leostereo has asked for the wisdom of the Perl Monks concerning the following question:
Hello monks: I was tryng to feed a file with last ip granted by my dhcp server. Trying to inspect dhcpd.log file using tail, I tryed a simple code from documentation. test.pl
#!/usr/bin/perl use File::Tail; $file=File::Tail->new("/var/log/dhcpd.log"); while (defined($line=$file->read)) { print "$line"; }
Here dont get any output nor error so, then I tryed other piece of code that works ok. test2.pl
Can someone give me a clue? What is the difference ; why test1 dont work and dont print even an error message and test2 works ok ? I hope it can be usefull to someone. Regards, Leo.#!/usr/bin/perl -w use File::Tail; sub find_aaa_name { return '/var/log/dhcpd.log'; } my $file = File::Tail->new( name =>'/opt/dhcp_tail/dummy.txt', interval => 1, maxinterval => 1, resetafter=> 5, name_changes=> \&find_aaa_name, ignore_nonexistant => 1 ); while (defined($line = $file->read)) { print $line,"\n"; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File::Tail can not get output
by toolic (Bishop) on Oct 08, 2015 at 20:57 UTC | |
by leostereo (Beadle) on Oct 11, 2015 at 01:08 UTC | |
|
Re: File::Tail can not get output
by Discipulus (Canon) on Oct 09, 2015 at 08:12 UTC | |
|
Re: File::Tail can not get output
by stevieb (Canon) on Oct 08, 2015 at 20:36 UTC |