use Tk 800.000; use strict; use Tk::LineNumberText; use IPC::Run qw(start finish); my $MW = MainWindow->new; my $cmd_output = $MW->LineNumberText(-widget=>'ROText')->pack(-fill=>'both',-expand=>1); my $harness = start(['cmd.exe','/C','echo hello'] , '<' ,\undef , ">pipe", \*OUT,debug=>999) || die $!; $MW->fileevent(\*OUT,'readable',[\&mycb,\*OUT,$harness]); MainLoop; sub mycb { $cmd_output->insert('end',"Callback called\n"); my ($fh, $harness) = @_; my $n = sysread( $fh, my $buf, 8192 ); if($n) { $cmd_output->insert('end',$buf); return; } $cmd_output->insert('end',"WARNING: $!") if not defined $n; $MW->fileevent( $fh, 'readable', '' ); close $fh; $harness->finish; }