fluffyvoidwarrior has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Erstwhile Monks, I'm working on a windows GUI program using Tk and Activestate Perlapp to make a standalone executable. I want to call a system command without popping up a dos window in the middle of my pretty Tk GUI. Any Ideas. Many Thanks to you yet again!

Replies are listed 'Best First'.
Re: Backticks, console Tk and perlapp
by thundergnat (Deacon) on Dec 13, 2005 at 18:19 UTC

    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.

Re: Backticks, console Tk and perlapp
by zentara (Cardinal) on Dec 13, 2005 at 17:59 UTC