Hi again...
I've worked out how to use this... and in the CGI, I'm trying to redirect STDOUT to a file... which works fine... EXCEPT that all child processes created with Win32::Process will NOT direct their output to the file that's opened... and this is how I'm creating the processes...
sub CopyProcess {
my ($strSource, $strDest) = @_;
my $obj;
my $command = "xcopy ".$strSource." ".$strDest." /f /u /y";
Win32::Process::Create ($obj,
"c:/windows/system32/cmd.exe",
"cmd /c ".$command,
1,
NORMAL_PRIORITY_CLASS,
'.'
) || die "Win32::Process::Create: $! ($^E)";
return $obj;
}
This all works fine in a console... so once again... I'm afraid that this sort of thing doesn't work right when handled as a CGI...
Thoughts?
Andy Speagle
-----
On 4/26/06, $Bill Luebkert <[EMAIL PROTECTED]> wrote:
Andy Speagle wrote:
> Bill,
>
> Yes... this works from the command-line... but I was having other fork()
> related issues from the command-line too... fork() emulation just isn't
> stable with win32... I was already trying to reason out something with
> Win32::Process... but I'm missing some of the magic I think in getting a
> proper process fired up...
>
> Could you give me an example of how this might work?
Totally untested:
use strict;
use warnings;
use Win32::Process;
my @unc_path = (stuff, in, here);
my @children;
foreach (@unc_path) {
my $obj = run_process ($_);
push @children, $obj;
)
my @current_children;
while (1) {
foreach (@children) {
my $res = $_->Wait(0);
push @current_children, $_ if $res != 1;
}
@children = @current_children;
last if not @children;
sleep 2;
}
exit 0;
sub run_process {
my $Obj;
Win32::Process::Create($Obj,
'C:/sometask.exe',
"C:/sometask.exe @_",
0,
DETACHED_PROCESS,
".") or die "Win32::Process::Create: $! ($^E)";
return $Obj;
}
__END__
_______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
