in reply to redirecting stdin on windows

A few years ago, I wrote a magazine article detailing how to mix "main" and "WinMain" concepts in a Win32 program, and how the differences weren't exactly clear cut. I don't have a copy handy, alas.

However, I use stdout and stderr in GUI programs all the time, for debugging/logging. It's harmless and does nothing unless the program was started with redirected output. I think stdin is the same way: if you have a GUI program and don't supply a file handle when it's started (i.e. "redirect" it), it is connected to nothing. A Console program, on the other hand, will create a new console the first time it is needed, it it wasn't hooked up to anything (because it was launched by a GUI process or with flags telling it not to).

Hmm, on rereading, I think you don't need any of that. You are asking about ordinary command-line programs, right? Your problem is that | won't give you both input and output at the same time?

In that case, see the module IPC::Open2. It does exactly this.

—John

Replies are listed 'Best First'.
Re: Re: redirecting stdin on windows
by arkamedis21 (Acolyte) on Aug 20, 2002 at 18:56 UTC
    I tried that I don't think it works on windows.
      The comment in the open3.pm file (which open2 calls) says, "...ported to Win32 by Ron Schmidt,..."

      There are issues about ActiveState Perl launching outside programs at all; you may have a problem unrelated to the double piping.