hebus has asked for the wisdom of the Perl Monks concerning the following question:
I want use open3 function in perl daemon. Into the code i have closed STDOUT and open3 produce nothing. following is little script to reproduce my error
use strict; use IPC::Open3 ; use Data::Dumper ; my $auth ="admin1" ; my $pwd = "admin1" ; close(STDOUT) ; my $cmd = "net rpc rights list -U $authname%$pwd" ; my ( $wfh,$rfh,$efh,$pid,@privilege) ; $pid = open3( $wfh ,$rfh, $efh, $cmd ); open(FH,">/tmp/debug") ; waitpid( $pid, 0 ) ; if ( $? == 0 ) { print FH "Cmd OK\n" ; while(<$rfh>) { print FH $_ ; } } close(FH) ;
I don't understand why i can't use open3 when STDOUT is closed. I have tried to open annother file with :
open OUT, ">/tmp/out.tmp" or die "Can't open OUT" ; $pid = open3( $wfh ,\*OUT, $efh, $cmd ); ... ... while (<OUT>) { print FH $_ ; }
this produce the same problem
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: closed STDOUT and open3
by zentara (Cardinal) on Feb 04, 2010 at 12:20 UTC | |
|
Re: closed STDOUT and open3
by ikegami (Patriarch) on Feb 04, 2010 at 15:28 UTC | |
by ambrus (Abbot) on Feb 04, 2010 at 19:52 UTC | |
|
Re: closed STDOUT and open3
by Anonymous Monk on Feb 04, 2010 at 12:23 UTC | |
by ikegami (Patriarch) on Feb 05, 2010 at 00:13 UTC |