Re: Proc::Simple - Poll




<jdenevan@xxxxxxxxxxx> wrote in message
news:1137621165.154841.50490@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

> Hello,
> I have a perl script that runs continuously and launches other Perl
> scripts. I'm using Proc::Simple to do this.
..
..
>
> I'm using ActivePerl on a WinXP Pro box.

Proc::Simple doesn't work properly on Win32. Most of the tests fail.
You would be better off using Win32::Process - which you'll already have
since you're using AS perl. Here's a tested example (that won't necessarily
do *exactly* what you want):

use warnings;
use strict;
use Win32::Process;

my $timeout = 1000; # milliseconds

my $ProcessObj;
my $exe = "D:\\perl\\bin\\perl.exe"; # modify as needed
my $cmdline = "perl myScript.pl";
my $priority = NORMAL_PRIORITY_CLASS;
my $console_flag = CREATE_NEW_CONSOLE; # eg

Win32::Process::Create(
$ProcessObj,
$exe,
$cmdline,
0,
$priority | $console_flag,
"."
)|| die $^E;

# Wait() returns '1' if the process finished
# during the timeout period. Else returns 0.

while(!($ProcessObj->Wait($timeout))) {
print "It's still running\n";
}

print "myScript.pl has finished\n";

__END__

'perldoc Win32::Process' is not as helpful as it might be (but check it out,
anyway). There's good documentation of his module in Chapter 8 of Dave
Roth's "Win32 Perl Programming: The Standard Extensions" (if you have access
to that book).

Cheers,
Rob


.



Relevant Pages

  • RE: Segmentation Fault(Core dumped)
    ... But when I started testing my perl script, ... Compilation failed in require at ./test.pl line 13. ... > official business of Sender. ...
    (perl.dbi.users)
  • Re: sharing variables-data perl-asp
    ... Also how do you invoke a perl script from an active server page? ... ASP in Perl. ... Why do you want to shell out to perl when you're already running perl? ...
    (comp.lang.perl.misc)
  • Re: environment variables in perl scripts
    ... Define a BEGIN block in your perl program. ... > perl script, something like: ... > environment variables are there and diag.txt shows ... > This communication is intended for the use of the ...
    (perl.dbi.users)
  • Re: kill process when file count reached,,.
    ... an infinite loop there, ... IMO you could just use readdir and grep in perl. ... You're using awk in backticks in a perl script? ... Perl has a kill builtin, why the hell not use that. ...
    (comp.lang.perl.modules)
  • Re: associating .pl extension with perl
    ... > On my laptop Linux system, I can execute perl scripts ... > associated with perl. ... interpreter that will execute the code contained therein. ... > I discovered this problem when using a perl script that I wrote on my ...
    (comp.lang.perl.misc)