Link to home
Start Free TrialLog in
Avatar of tindavid
tindavid

asked on

How to write "tail -f " in Perl and running in Windows

I need to write a Perl script to read a logfile (that is continuesly written by another process).

I need to have this script be able to run both in Windows (XP) and Unix, please tell me what version of Perl binary should I use.
I have tried Strawberry Binary but it still required Tail.pm that Strawberry binary does not have by default.
ASKER CERTIFIED SOLUTION
Avatar of ghostdog74
ghostdog74

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Tintin:  That is a great way of installing packages.  I was not aware of this.  I had to swap the single quotes with double.  I posted the install process, take a look at the end.  Can you explain the "install seems impossible"?

Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
 
C:\Documents and Settings\User>perl -MCPAN -e 'install File::Tail'
Can't find string terminator "'" anywhere before EOF at -e line 1.
 
C:\Documents and Settings\Daniel1>perl -MCPAN -e "install File::Tail"
CPAN: Storable loaded ok
CPAN: LWP::UserAgent loaded ok
Fetching with LWP:
  http://ppm.activestate.com/CPAN/authors/01mailrc.txt.gz
Going to read C:\Perl\cpan\sources\authors\01mailrc.txt.gz
Fetching with LWP:
  http://ppm.activestate.com/CPAN/modules/02packages.details.txt.gz
Going to read C:\Perl\cpan\sources\modules\02packages.details.txt.gz
  Database was generated on Fri, 07 Mar 2008 11:31:35 GMT
 
  There's a new CPAN.pm version (v1.9205) available!
  [Current version is v1.7602]
  You might want to try
    install Bundle::CPAN
    reload cpan
  without quitting the current session. It should be a seamless upgrade
  while we are running...
 
Fetching with LWP:
  http://ppm.activestate.com/CPAN/modules/03modlist.data.gz
Going to read C:\Perl\cpan\sources\modules\03modlist.data.gz
Going to write C:\Perl\cpan\Metadata
Running install for module File::Tail
Running make for M/MG/MGRABNAR/File-Tail-0.99.3.tar.gz
Fetching with LWP:
  http://ppm.activestate.com/CPAN/authors/id/M/MG/MGRABNAR/File-Tail-0.99.3.tar.
gz
CPAN: Digest::MD5 loaded ok
Fetching with LWP:
  http://ppm.activestate.com/CPAN/authors/id/M/MG/MGRABNAR/CHECKSUMS
Checksum for C:\Perl\cpan\sources\authors\id\M\MG\MGRABNAR\File-Tail-0.99.3.tar.
gz ok
Scanning cache C:\Perl/cpan/build for sizes
CPAN: Archive::Tar loaded ok
File-Tail-0.99.3/
File-Tail-0.99.3/META.yml
File-Tail-0.99.3/t/
File-Tail-0.99.3/t/20tail.t
File-Tail-0.99.3/t/30name_change.t
File-Tail-0.99.3/t/10open.t
File-Tail-0.99.3/select_demo
File-Tail-0.99.3/Tail.pm.debug
File-Tail-0.99.3/Changes
File-Tail-0.99.3/logwatch
File-Tail-0.99.3/MANIFEST
File-Tail-0.99.3/Tail.pm
File-Tail-0.99.3/Makefile.PL
File-Tail-0.99.3/README
 
  CPAN.pm: Going to build M/MG/MGRABNAR/File-Tail-0.99.3.tar.gz
 
 
File::Tail will be installed without debugging information.
This information isn't usefull unless you intend to tinker
with the code. To install with debugging enabled, use:
perl Makefile.PL LOGIT
Checking if your kit is complete...
Looks good
Writing Makefile for File::Tail
'nmake' is not recognized as an internal or external command,
operable program or batch file.
  nmake  -- NOT OK
Running make test
  Can't test without successful make
Running make install
  make had returned bad status, install seems impossible
 
C:\Documents and Settings\User>

Open in new window

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Tintin
Tintin

Strawberry Perl (which I hadn't previously heard of) comes with dmake.  It is designed to supposedly make installing CPAN modules (particular XS modules) easy as it comes with a C compiler and associated utilities.

From the output you posted, it appears you have now installed ActivePerl, in which case use

ppm install File-Tail

as mentioned by Adam.

ActivePerl is certainly the most popular Perl distribution for Windows, but I'd have to say that Strawberry Perl looks very promising.
I'd never heard of Strawberry perl either - but just reading their website, it sounds very nice.  The ppm system that ActiveState is great, until you want a package that isn't available.  Getting everything going needed to install from source on windows is a pain - if a package isn't available through ppm, I usually look for another way to do it on windows.
The information given is all valid and useful, so recommend no delete.