It is possible to accomplish what you want, but not straightforwardly. The problem is that DOS does not have any such concept as STDERR, at least not in anything like the Unix sense of that term.

Traditionally, DOS software does not print error messages to the console unless they are fatal and the program is bailing back out to the prompt immediately, in which case there was (think DOS here, not a command box window on Windows, which is intended as a compatibility measure only) no point whatsoever in being able to redirect that output, since it would typically be one sentence long and the user would be getting a prompt. (Remember that DOS was not intended to be Unix, to run on university computers where people were developing software and doing research; it was intended to sell to businesses for things like spreadsheets.) For more verbose error messages in the DOS world, you either explain it onscreen in a fashion that is integrated with the rest of your app (think: text-based dialog box) or else you write it to a log file. For these hysterical raisins, DOS did not have a redirectable STDERR, which leads to your current problem. All C libraries for DOS and for Windows face this issue: do we want to support compiling Unix software that assumes it can just write willy nilly to STDERR, and if so how? The usual approach is to make STDERR synonymous with the console, which is IMO absolutely the wrong way to do it. (What the C libraries probably should have done, back in the eighties, is point it to C:\STDERR.LOG, but it's far too late for that now. What C libraries IMO should be fixed to do now is show these messages in a window available by clicking an icon in the system tray -- but nobody listens to me.) What just about all C libraries do, as I said, is map it to the non-redirectable console. (The console is not by its nature intended to be redirectable; it is not in any sense a stream. The BIOS calls that most C libraries use for writing to it can just as well be used to draw text-based pulldown menus and dialog boxes; they support absolute positioning and that sort of jazz, rather more like ncurses than STDERR on Unix.) As a result, the C library's standard error stream is largely useless on DOS -- and also on Win32 by extension. My advice is, don't use it, in Perl or any other language, if your code needs to support Windows.

However, Windows 95 and later come with some facilities like multitasking that will allow you to fake it, particularly since in Perl it is possible to close off STDERR and open it pointing to something else (something _other_ than the C library's concept of STDERR), such as a pipe or log file. This is what you should do.


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/

In reply to Re: Open a second DOS window by jonadab
in thread Open a second DOS window by bart

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.