Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: How can I redirect STDOUT and STDERR from a program on WIN32?

by tilly (Archbishop)
on Aug 10, 2000 at 23:32 UTC ( [id://27361]=note: print w/replies, xml ) Need Help??


in reply to How can I redirect STDOUT and STDERR from a program on WIN32?

I have used IPC::Open3 for this and found it worked well both on Unix and Windows. If $cmd has your command then:
use IPC::Open3; open3("<&STDIN", \*CAPTURE, \*CAPTURE, $cmd) or die "Cannot run $cmd: +$!";
Now you are reading both STDERR and STDOUT of the file from CAPTURE.

I don't know how to do this and get return codes as well though, the return of open3 is a process ID. Also note that you need to be careful with mixing filehandles. Should you try to get output while it is giving you input, programs take a while to get bored with that sort of silliness...

Replies are listed 'Best First'.
Re: Answer: How can I redirect STDOUT and STDERR from a program on WIN32?
by stdout (Initiate) on Oct 03, 2004 at 19:27 UTC
    any idea about getting the return code ? :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-03-30 01:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found