in reply to TK::ExecuteCommand

A few comments:
First, regarding your program's output. Proc::Killfam.pm has the following lines (14 and 15):
# We need Proc::ProcessTable to work properly. If it's not available, # then we act like Perl's builtin kill() command.
The first line of your output is simply an FYI warning. Thus, it is not the reason your program is not working. Rather, the second line
Can't call method "ExecuteCommand" on an undefined value at D:\...\exe +c.pl line 1.
which has nothing to do with the first line, is why it fails. There is a coding error in the example you are trying to run. Since you haven't posted it, we cannot tell you what it might be.

Second, Proc::ProcessTable does work under Windows, but you need to have cygwin install. The following is from the Readme file bundled with the Proc::ProcessTable module:

"Please note that the windows port requires the Cygwin environment to work".

If you want cygwin, you can get it here

Third, from the Tk::ExecuteCommand manpage, the primary purpose of Tk::ExecuteCommand is to provide non-blocking program execution. Yet it still provides the functionality you want. That is, you can still use it if you want to redirect program output to a window. However, it will only work with output that typically goes to a console window (like the dos dir command). Try the following code (modified from the manpage):
use Tk; use Tk::ExecuteCommand; my $mw = MainWindow->new; $ec = $mw->ExecuteCommand( -command => '', -entryWidth => 50, -height => 10, -label => '', -text => 'Execute', )->pack; $ec->configure(-command => 'dir'); $ec->execute_command; $ec->bell; $ec->update; MainLoop;
Or, you can take that part of Tk::ExecuteCommand that handles the output redirection and use it as a basis for a custom-made solution.

davidj

Replies are listed 'Best First'.
Re^2: TK::ExecuteCommand
by vikee (Sexton) on Jun 24, 2004 at 11:33 UTC

    here is the code, it is from the book mastering perl/tk.
    also i chaned the command, cause this one here is for unix.

    Edit by BazB: remove pre tags around text and add readmore tags around code.

      If this is the code you tried to run as D:\...\exec.pl, then that is your problem. This code is the module definition for Tk::ExecuteCommand. It cannot be executed by itself. Forget about trying to run it. If you are on windows, use ppm to install the module from one of the repositories and test it with the example code I have already posted.

      davidj
        thanks problem solved
        $ec->terse_gui;
        has to be called to disable the gui.