开发者

monitoring an exe application launching

I need to monitor an 开发者_运维问答console exe application which don't have any stdin from the user it only print some info to the screen i used a POE:Wheel for this task

Below are my code:

use POE qw( Wheel::Run);

    POE::Session->create(
      inline_states => {
         _start => sub {
            my ($heap) = $_[HEAP];

            my $run    = POE::Wheel::Run->new(
                Program      => "my_program.exe",
                StdoutEvent  => "print"
            );


            $heap->{run}  = $run   ;

         },

         print => sub {print "somthing";}
      }
    );
$poe_kernel->run(  );

When i run the above code/script and run the my_program.exe i didn't see any print on the screen could someone tell what could be my problem here .


What could be my problem here

Three likely candidates as far as I see:

  1. my_program.exe ran but produced no output
  2. my_program.exe could not be executed
    The program is not in the path, has the wrong permissions, isn't an executable, etc.
    A StderrEvent is perhaps the easiest way to catch this, as the child process will warn() about the failure to exec().
  3. Your output is line buffered
    The "print" state handler emits output without a newline, which might not appear until perl's termination when output buffers are flushed. Your script won't terminate, however, until the {run} wheel is removed from the session's HEAP, which you can (and should) do in a sig_child handler.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜