Hi
{NULE}
<pr>Thanks a lot!! Here is what I came up with. Please comment on this!
<pr>
#!/usr/local/bin/perl
use strict;
use Tk;
use Tk::DialogBox;
use Tk::ProgressBar;
my (@joblist, $job, $pid);
# Get a list of all jobs currently running..
chdir();
open (IN, ".dractrack") or die "Can't open .dracktrack for input $!\n"
+;
while (<IN>){
chomp;
push (@joblist, $_);
}
close IN;
if (@joblist=""){print" dractrack - Nothing currently in the que!\n";}
# For each new job create a window and display the stats
foreach $job ( @joblist) {
if( $pid = fork ) {
} elsif( defined $pid ) {
my %drac;
($drac{type},$drac{primary},$drac{rundir},$drac{printfile},$drac{h
+ostname},$drac{stages}) = split / /, $job , 6;
my $MW = new MainWindow(-title => "Vampire $drac{type} : $drac{pri
+mary}");
my $progress = $MW->ProgressBar(
-width => 25,
-length => 300,
-borderwidth => 2,
-relief => 'flat',
-width => 20,
-padx => 2,
-pady => 2,
-colors => [0 => 'green', .8*$drac{stages}=>'yellow' , .9*$dra
+c{stages} => 'red'],
-resolution => 1,
-blocks => 100,
-anchor => "w",
-from => 0,
-to => $drac{stages},
)->pack(-fill=>"x");
my $stats = $MW->Label(-text=>"Type:$drac{type} Cell: $drac{prim
+ary} Host: $drac{hostname} Total Stages: $drac{stages}",
-font => '-b&h-lucida sans typewriter-medium-*-*-*-*-*-*-*-*-*
+-*-*',
-relief=>"sunken",
-borderwidth=>2,
-anchor=>"w")->pack;
&CheckStage( $MW, $progress, $drac{rundir}, $drac{printfile}, $dra
+c{stages});
MainLoop;
exit;
}else {
die "Can't fork: $!";
}
}
# Delete .dractrack dir
chdir();
open (DRACNEW, ">>.dracnew") or die "I think dracktrack is running";
rename (".dracnew", ".dractrack") or die "Can't replace .dracktrack.."
+;
sub CheckStage {
my ($MW, $progress, $path, $log, $stages) = @_;
my @lstage = 0;
while ($lstage[3] < $stages){
open( LOG, "$path$log".".log" )
or die "Cannot open $path$log.log for input: $!\n";
while( <LOG> ) {
chomp $_;
next if ($_ !~ m/AT STAGE:/);
@lstage = split /\s+/, $_;
}
close LOG;
$progress->value($lstage[3]);
$MW->update;
sleep(1);
}
$MW->destroy;
}
Once again thanks!
Rhodium
The <it>seeker</it> of perl wisdom.