Debian Codegraph @

examples/fedemo

raw
1 #!/usr/local/bin/new/perl -w
2 use strict;
3 my $FILE_LOG = (@ARGV) ? shift : 'README';
4
5 use Tk;
6
7 my $top = MainWindow->new;
8 my $t = $top->Scrolled('Text')->pack(-expand => 1, -fill => 'both');
9 my $b = $top->Button(-text => 'Quit', -command => [destroy => $top])->pack;
10 init_check();
11 MainLoop;
12
13 sub init_check
14 {
15 # my $cmd = "/usr/bin/tail +0f $FILE_LOG";
16 my $cmd = "ls -l ";
17
18
19 my $open_pid = open (TAIL, "$cmd|") || die "Can't open $cmd: $!";
20
21 select (TAIL); $| = 1;
22 select (STDOUT); $| = 1;
23
24 $top->fileevent(\*TAIL, 'readable',
25 sub {
26 my $line = <TAIL>;
27 if (defined $line)
28 {
29 $t->insert('end',$line);
30 $top->idletasks;
31 }
32 else
33 {
34 close(TAIL);
35 }
36 });
37 }
38