Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm not particularly attached to using open3, I just want a way to connect my stream to to the external program. Am I missing something obvious or is this a limitation of open3? I've been avoiding IPC::Run so far as this will be copied to several computers & I'd prefer not to use a separate module. It's even fine if I can't redirect zfs receive's STDOUT or STDERR, as long as I can just connect STDIN and get the exit status. Thanks!#!/usr/bin/perl use warnings; use strict; use IO::Socket; use IPC::Open3; my $sock = new IO::Socket::INET ( LocalHost => '127.0.0.1', LocalPort => '1818', Proto => 'tcp', Listen => 1, ReuseAddr => 1, Timeout => 20 ); die "Could not create socket: $!\n" unless $sock; ## THIS WORKS (I can telnet to port 1818 from another terminal & see t +he text come across): #my $new_sock = $sock->accept() or die "No one came!"; #while ( <$new_sock> ) { print; } ## THIS WORKS (If I type "cat | ./<this_script>, I can type and see it + echo back): #my $pid = open3( "<&STDIN", ">&STDOUT", ">&STDERR", "/bin/cat" ); #waitpid( $pid, 0 ); # THIS DOES NOT WORK (using open3 to read from a network handle). my $new_sock = $sock->accept() or die "No one came!"; #my $pid = open3( $new_sock, ">&STDOUT", ">&STDERR", "/bin/cat" ); # c +an telnet to port but immediately disconnected my $pid = open3( $new_sock, $new_sock, ">&STDERR", "/bin/cat" ); # can + telnet to port but immediately disconnected waitpid( $pid, 0 ); close($sock);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: IPC::Open3 not connecting network socket handle
by ikegami (Patriarch) on Jul 23, 2009 at 22:23 UTC | |
by Anonymous Monk on Jul 24, 2009 at 15:08 UTC | |
by ikegami (Patriarch) on Jul 24, 2009 at 15:49 UTC | |
by Anonymous Monk on Jul 24, 2009 at 17:01 UTC | |
by ikegami (Patriarch) on Jul 24, 2009 at 17:16 UTC | |
|
Re: IPC::Open3 not connecting network socket handle
by salva (Canon) on Jul 24, 2009 at 07:00 UTC | |
by ikegami (Patriarch) on Jul 24, 2009 at 07:19 UTC | |
by salva (Canon) on Jul 24, 2009 at 09:50 UTC | |
by ikegami (Patriarch) on Jul 24, 2009 at 16:33 UTC |