Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: STDERR going to string

by Anonymous Monk
on Oct 10, 2011 at 13:38 UTC ( #930631=note: print w/replies, xml ) Need Help??


in reply to Re^2: STDERR going to string
in thread STDERR going to string

If you want to capture STDIN/STDOUT/STDERR, you have to launch another process, see IPC::Run3, IPC::System::Simple

Replies are listed 'Best First'.
Re^4: STDERR going to string
by philkime (Sexton) on Oct 11, 2011 at 08:21 UTC
    It's not really the output of an external command etc. I need. It's the STDERR of a C library which an XS module uses. So when I make certain sub calls, it gets into the C routines and it's their STDERR I want to capture. It all works fine on non-Windows using STDERR redirection to a file or Capture::Tiny but on Windows, the STDERR of the library refuses to be captured. This seems to be a windows specific thing - I read somewhere that re-opening STDERR on windows de-couples perl STDERR from the C library STDERR. If so, I'm really in the dark as to how to capture this.

      ...repetitive...I'm really in the dark as to how to capture this.

      Like I already said, launch a process

      perl foo.pl 1>my.stdout.txt 2>my.stderr.txt always works

        I don't think I understand how to do that in my case. I am in the middle of a large program and need to make some sub calls to some XS/external lib subs. There isn't anything I can really launch as an external processs here. Am I missing something? I know it'll always work if I redirect everything before I start but my problem is that I am already deep in some code at the point where I need to run some XS subs and get their STDERR.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://930631]
help
Chatterbox?
[msh210]: I think I just found a lie in perldoc.
[msh210]: warn: "If the last element of LIST does not end in a newline, it appends the same file/line number text as die does."
[msh210]: perl -e'warn "test$/", "" '
[msh210]: doesn't append anything.
[msh210]: It should say "If the last nonempty element of LIST" or "If the string thus to be printed does not end in a newline""
[msh210]: Am I wrong?
[shmem]: no. You're right.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2017-04-24 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (439 votes). Check out past polls.