user786 has asked for the wisdom of the Perl Monks concerning the following question:

I need to tail a log file as i run some commands on a cisco router. I used perl cpan File::Tail module.

my $file = File::Tail->new("logs/nameoflogfile"); while(defined(my $line = $file->read)) { print "$line\n"; }

I get the following error : Error opening "filename" No such file or directory

Checked the following

1)File exists -->yes 2) Name of the file is correct, Path is correct.-->yes 3)I tried to tail a different file with the same script in my local host(not in router) it worked. 4)However on the router# it doesn't work. Any suggestions ?

Replies are listed 'Best First'.
Re: perl File::tail log files.
by aitap (Curate) on Jun 21, 2014 at 05:20 UTC

    I need to tail a log file as i run some commands on a cisco router.
    Do you change directory anywhere in your script? Try inserting use Cwd; print getcwd(), "/logs/nameoflogfile ", (-e getcwd()."/logs/nameoflogfile" ? "exists" : "does not exist"), "\n" before the place where you open the file.
    I tried to tail a different file with the same script in my local host(not in router) it worked.
    Does this mean that you need to tail a log file on the remote host (CISCO router)? That could be a bit difficult.

Re: perl File::tail log files.
by Anonymous Monk on Jun 21, 2014 at 08:53 UTC

    However on the router# it doesn't work.

    What does "on the router" mean? In technical terms please

      1) I ssh into a cisco router. 2)tail the log file 3) execute commands

        See if File::SmartTail would help any.

        And I myself would rather use File::Tail::Multi than File::Tail for former supports filtering (besides being able to tail multiple files).

        Feb 15, 2019- cpan command "i /File::Tail::Multi/" does not find the module anymore. FWIW.

Re: perl File::tail log files.
by 1s44c (Scribe) on Jun 23, 2014 at 21:58 UTC
    Use an absolute path for the file you are trying to tail? If that works you know it's a path issue.