I'll have a look at the package, thanks for the tip.  What I wanted overall was 
to have perl cause a system beep, repeatedly, until you came and hit a key 
after a hardcoded process related to the nohup file had exited.

My code follows, not sure if perl would allow me to ween from ps and awk or 
not.  Im getting a ton of Spawned Process XXXXXX messages, which even if i can 
surpress those, it now feels as if its not the most efficient manner =)

#! /usr/local/bin/perl

use Term::ReadKey;
use IO::Handle;

my $key;
my $nohupfile=$ARGV[0];

print "ptail v1.0\n\n";
die "\n***** usage: ptail <filename>\n\n" unless defined ($ARGV[0]);

open (NOHUPFILE, $nohupfile) or die "\ncan't open $nohupfile: $!\n\n";
seek (NOHUPFILE,50,2);

my $CMD= qq { ps -a | awk '{ if (\$4=="adpatch") print \$1 }' | tail -1 };  
#hardcoded to look for any Oracle adpatch binary process.  
print "DEBUG: CMD: $CMD\n";
#exit;
my $process=`$CMD`;

if (length($process) == 0) {
    print "ERROR: Patching Process not found.\n";
    exit;
}

print "DEBUG: Process: $process\n";
#exit;

my $doneflag=0;

while (!$key) {
       $key=ReadKey(-1);
       if ($key) {
           last;
       }
       while (<NOHUPFILE>) {
              print
       }
       if (!$key) {
           sleep 2;
           $CMD= 'ps -a | awk \'{ print $1 }\''  ;
           if ((grep /$process/, `$CMD`) < 1) {
              print "[[ Patching Complete ]]";
              print "";    #insert ^V^G here
              sleep 2;
           }
       } else {
           last;
       }
       NOHUPFILE->clearerr();
}




----- Original Message -----
From: "Thomas, Mark - BLS CTR" <[EMAIL PROTECTED]>
Date: Tuesday, February 22, 2005 9:43 am
Subject: RE:  tail a file [was: subscriber]

> The default setting of File::Tail behaves the way you want. 
> Perhaps that is
> an easier solution.
> 



_______________________________________________
Perl-Unix-Users mailing list
Perl-Unix-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to