It depends. If you don't need to interact with the program you are calling, just open it as a piped file handle.
use warnings;
use strict;
use Tk;
my $top = MainWindow->new;
my $text = $top->Scrolled('Text', -scrollbars => 'se')->pack;
my @commands = ('dir', "type $0", 'ping 127.0.0.1');
for my $command(@commands){
open my $fh, '-|', $command;
while (my $line = <$fh>){
$text->insert('end', $line);
$text->see('end');
$text->update;
}
$text->insert('end', "\n".('=' x 79)."\n");
}
MainLoop;
Update: Never mind, this doesn't do what you were asking. If there is already a console window open, this won't open a new one, however, if you suppress the console window on start with wperl, it will open one. Sigh. |