Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Perl ignores lines with bold characters from a pipe on Windows

by almut (Canon)
on Mar 03, 2007 at 04:25 UTC ( [id://603025]=note: print w/replies, xml ) Need Help??


in reply to Perl ignores lines with bold characters from a pipe on Windows

Just a wild guess: your mycmd might be mixing output via redirectable streams with "direct" console output via WriteConsole. AFAIK, the latter would typically be used to render highlighted text etc., making use of console "attributes". In particular, note that

Both WriteConsole and WriteFile can be used for console I/O. While WriteConsole supports writing Unicode characters to a console screen buffer, WriteFile does not. However, WriteConsole fails if it is used with a standard handle that is redirected to a file. (... more)

(emphasis added)

This might explain why some lines get lost when capturing redirectable output only (stdout).

As to why the console output does end up in the file test_shell when redirecting output from the shell command line, I don't know. Maybe some additional magic is going on in this case...(?)

Anyway, what kind of program is this? Do you have the sources? If not, you might try a tool like StraceNT to find out what API calls are being used... (in particular look for WriteConsole, WriteFile, etc.)

Replies are listed 'Best First'.
Re^2: Perl ignores lines with bold characters from a pipe on Windows
by kingkongrevenge (Scribe) on Mar 03, 2007 at 05:02 UTC
    This is a port from Unix (cleartool), so I doubt it's MS api oddities.

      I think it is the Win32 API oddity, as the Win32 console has no ANSI or terminal emulation. If you want to output any color or weirdo formatting, you have to output these by directly writing to the console window yourself, bypassing the STDOUT filehandle. Hence I guess that the programmers wanted to keep their fancy feature of bold output and hence destroyed the ability to redirect the whole output.

        I think you've nailed the culprit.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://603025]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-19 14:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found