Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

bsdz's scratchpad

by bsdz (Friar)
on Oct 11, 2004 at 22:22 UTC ( [id://398318]=scratchpad: print w/replies, xml ) Need Help??

use Win32::Job; use Data::Dumper; use IO::File; my $fh = new IO::File; tie(*$fh => 'RedirectHandle', \&debug); $job = Win32::Job->new; my $pid = $job->spawn("cmd.exe", q{cmd /c dir}, { stdin => 'NUL', stdout => \*$fh, stderr => \*$fh, }); print $fh $pid; $ok = $job->run(30); print $fh Dumper($job->status); print $fh "Applications finished ok!" if $ok; exit; sub debug { foreach (@_) { map { print "# $_\n" } split /\n/; } } { package RedirectHandle; sub print_handle { my $this = shift; my $handle = $this->{HANDLE}; if (ref($handle) eq 'SCALAR') { $$handle .= $_[0] } elsif (ref($handle) eq 'CODE') { &$handle($_[0]) } else { print $handle $_[0] } 1; } sub TIEHANDLE { my $class = shift; bless({ HANDLE => $_[0] }, $class); } sub PRINT { my $this = shift; $this->print_handle(join("", @_)); } }
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (8)
As of 2024-03-28 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found