6 Einträge, 1 Seite |
1
2
3
4
5
$cmd = "tail -f /var/log/messages";
$fh = new IO::File;
my $pid = $fh->open ("$cmd|");
die "can't fork: $!\n" unless defined $pid;
Glib::IO->add_watch (fileno $fh, [qw/in hup err/],\&watch_callback, $fh);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
sub watch_callback {
my ($fd, $condition, $fh) = @_;
if ($condition >= 'in') {
my $data = scalar <$fh>;
if (defined $data) {
my $buffer = $textview1->get_buffer;
$buffer->insert ($buffer->get_end_iter, $data);
}
}
if ($condition >= 'hup' or $condition >= 'err') {
$fh->close;
$fh = undef;
}
if ($fh) {
return TRUE;
} else {
return FALSE;
}
}
1
2
3
$main->repeat(1000, sub { $log = qx(tail -f /var/log/messages) });
$main->Label(-textvariable => $log)->pack();
6 Einträge, 1 Seite |