markseger has asked for the wisdom of the Perl Monks concerning the following question:
When I run it there is no output. I even put a print right after the first call to make sure it gets to the while line and it does. Any ideas what I could try to see what's wrong?#!/usr/bin/perl -w use File::Tail; $file=File::Tail->new("/tmp/xxx"); while (defined($line=$file->read)) { print "$line"; }
I even tried eliminating the while and simply doing the read since I know there's something in the file:
and when I run it, it seems to be hanging on the read. The doc says you can pass it a non-zero value for debug so I tried 99 and got nothing. It feels like the file isn't getting opened but I have no ideas why.use File::Tail; $file=File::Tail->new("/tmp/xxx"); print "opened\n"; $line=$file->read; print "after read\n"; print "$line";
Finally I tried getting even more creative with more instrumentation as well as some error handling.
It now looks like $! is getting set to "Inappropriate ioctl for device", but only when I report it with ERROR2 and not ERROR1. Is that message even real? In other words the constructor doesn't seem to be failing. I'm real confused by what I'm seeing.use File::Tail; $file=File::Tail->new(name=>"/tmp/xxx", debug=>99, interval=>1, maxint +erval=>1) or print "ERROR1: $!\n"; print "ERROR2: $!\n"; print "opened\n"; $line=$file->read; print "after read\n"; print "$line";
-mark
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I can't get the sample code for File::Tail to read my file
by toolic (Bishop) on Dec 21, 2011 at 19:51 UTC | |
|
Re: I can't get the sample code for File::Tail to read my file
by Eliya (Vicar) on Dec 21, 2011 at 20:29 UTC | |
|
Re: I can't get the sample code for File::Tail to read my file
by Sewi (Friar) on Dec 22, 2011 at 05:42 UTC |