sub component_window { my ($prch,$pid) = @_; if (!exists $prch->{window}) { my ($title) = $prch->{log} =~ m(/(\w+)/logFile); $prch->{window} = my $newwin = $prch->{widget}->Toplevel( -title => $title ); my $fr1 = $newwin->Frame; $fr1->pack( -side => 'top'); $fr1->Label( -text => 'Log File: ')->pack( -side => 'left'); $fr1->Label( -text => $prch->{log})->pack( -side => 'left'); my $fr2 = $newwin->Frame; $fr2->pack( -side => 'top'); $fr2->Button( -text => 'Close', -command => [$newwin => 'destroy']) ->pack( -side => 'left'); $fr2->Button( -text => 'Kill', -command => sub {system("kill $pid")}) ->pack( -side => 'left'); $newwin->bind( '' => sub {delete $prch->{window}}); my $txt = $newwin->Scrolled('ROText', -scrollbars => 'e', -height => 20, -setgrid => 'true', ); $txt->pack( -side => 'top'); $prch->{tailwin} = $txt; my $tail = Tk::IO->new( -linecommand => sub { tail_lines($prch, $_[0]) }); $tail->exec("tail -f $prch->{log}"); } } sub tail_lines { my ($proc,$text) = @_; print "tail_lines $text" if $debug; $proc->{tailwin}->insert('end' => $outstr); $proc->{tailwin}->see('end'); }