Skip Menu |

This queue is for tickets about the libwin32 CPAN distribution.

Report information
The Basics
Id: 16767
Status: resolved
Priority: 0/
Queue: libwin32

People
Owner: Nobody in particular
Requestors: info [...] endum.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.26
Fixed in: (no value)



Subject: Win32::Job stdout problem
I'm trying to use this script to get command's output into a scalar but it doesn't seems to work. It only works if filehandle is opened on a real file. use strict; use Win32::Job; use Data::Dumper; my $job = Win32::Job->new; my $buffer; open CHILDOUT,'>',\$buffer; $job->spawn("ipconfig.exe" ,"ipconfig /all" ,{stdin=>'NUL' ,stdout=>\*CHILDOUT ,stderr=>\*CHILDOUT } ); my $ok=$job->run(undef); print Dumper($buffer); close CHILDOUT; Tested on Perl 5.8.7 built for MSWin32-x86-multi-thread, ActiveState Build 815. Thank you.
[guest - Wed Dec 28 11:58:45 2005]: Show quoted text
> I'm trying to use this script to get command's output into a scalar > but it doesn't seems to work. It only works if filehandle is opened > on a real file.
That is indeed a limitation of the module. Since the Win32 API needs a real filehandle, making it work with tied filehandles etc. would be non-trivial. I'll update the documentation with this limitation. However, you can use Win32::Job with file handles returned by the pipe () function. You may run into I/O blocking issue though, so it may be better to use temporary files.