http://www.perlmonks.org?node_id=809504


in reply to help need to read a listening log file

Hi, this is the code in <code>-tags...
#!/usr/bin/perl use strict; use warnings; my $installLogFile = $ARGV[0]; my $destinationlocation = $ARGV[1]; sleep 1 until -f $installLogFile; chdir($destinationlocation) || die $!; print "Changing directory to $destinationlocation\n"; chdir('logs') || die $!; my $lastLine = `tail /1 $installLogFile`; chomp($lastLine); my $secondLastLine = `tail /2 $installLogFile`; chomp($secondLastLine); $secondLastLine =~ s/$lastLine//; chomp($secondLastLine); if($secondLastLine eq 'SUCCESSFUL') { print "successful\n"; } else { print " was not successful \n"; exit; }

Replies are listed 'Best First'.
Re^2: help need to read a listening log file
by jithu_indian (Initiate) on Nov 26, 2009 at 09:58 UTC
    Hi markuhs, thanks for the code , here the thing is I am automating GUI installation of application using win32 GUI module. once I click on install It will generate a log file and it took almost 40 min to 1 hr depending upon system resources. I tried the code provided by U . but it is coming once log is created and going to else coz the word 'SUCCESSFUL' only appear after 40 min , here I just want to tail the application until it reaches SUCCESSFUL , ofcourse if the installation didn't went of well we can't see the msg in log, there is constant keywork "TIME" at the end of the file ... So I want to tail the log file until it got the keyword "TIME" once it reads the keyword "TIME" then I can assume that installation is over either it is SUCCESSFUL or not, could u help in this.