in reply to How do I pipe a Win32::API Process to a handle?

Hmmm - no one else seems to want to take this one on, so I'll ask --

It appears that you trying to re-invent several wheels with redirecting output from processes, and the question is why ?

Back-ticks work just fine in capturing console output, and do not pop up a console window.

"Experience is a wonderful thing. It enables you to recognize a mistake when you make it again."
  • Comment on Re: How do I pipe a Win32::API Process to a handle?

Replies are listed 'Best First'.
Re: Re: How do I pipe a Win32::API Process to a handle?
by Grygonos (Chaplain) on Feb 23, 2004 at 20:26 UTC

    I'll second that... calling my $results = `ipconfig /all`; would be more than sufficient. Obviously you could also write this to a file

    #!/perl -w use strict; my $results = `ipconfig /all`; open(IPINFO, ">C:/ipconfig.out"); print IPINFO $results; close IPINFO;
    which does produce results formatted exactly the way you would see on the screen. In other words newlines and whitespaces are preserved when receiving output from a backticked command


    Grygonos
Re: Re: How do I pipe a Win32::API Process to a handle?
by Thelonius (Priest) on Feb 23, 2004 at 21:34 UTC
    Back-ticks work just fine in capturing console output, and do not pop up a console window.
    If your Perl process is not already associated with a console window, then backticks or open "cmd|" do open a new console window.

    I played around a little trying to get I/O redirection to work using the normal Perl IO constructs and/or POSIX dup2, but it didn't work. I see this Python program to solve the problem. This should be translatable to Perl.

    The only other hint I have is that there is already a Win32::Process module, so you don't have to call CreateProcess using Win32::API.