Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: IPC::Open3 misbehaving when STDOUT is not FD #1

by Anonymous Monk
on Jun 06, 2009 at 01:16 UTC ( [id://768966]=note: print w/replies, xml ) Need Help??


in reply to Re: IPC::Open3 misbehaving when STDOUT is not FD #1
in thread IPC::Open3 misbehaving when STDOUT is not FD #1

Portable?
#!/usr/bin/perl use warnings; use strict; use IPC::Open3; use Test::More tests => 1; use File::Spec; my $devnull = File::Spec->devnull; # Hide undesired output. open(STDOUT, '>', $devnull); open(STDERR, '>', $devnull); # Associate STDOUT and STDERR with # descriptors other than 1 and 2. open(local *STDOUT, '>', $devnull); open(local *STDERR, '>', $devnull); open3( undef, local *PIPE, undef, qq!$^X -le "print 111;print STDERR 222"!, ); my $pipe = ''; $pipe .= $_ while <PIPE>; is($pipe, "111\n222\n"); __END__

Replies are listed 'Best First'.
Re^3: IPC::Open3 misbehaving when STDOUT is not FD #1
by ikegami (Patriarch) on Jun 06, 2009 at 07:19 UTC
    $^X isn't properly converted to a shell literal. (i.e. Won't work if there's a space in $^X.) Fix:
    open3( undef, local *PIPE, undef, $^X, q!-le print 111;print STDERR 222!, );

Log In?
Username:
Password:

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

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

    No recent polls found