Peter Pentchev wrote in
<20200328111428.GA1431416(a)straylight.m.ringlet.net>:
|On Sat, Mar 28, 2020 at 01:12:35PM +0200, Peter Pentchev wrote:
|> On Thu, Mar 26, 2020 at 01:38:17PM +1100, Dave Horsfall wrote:
|>> On Wed, 25 Mar 2020, Grant Taylor via TUHS wrote:
|>>
|>>> · netcat's STDOUT to grep's STDIN
|>>> · grep's STDOUT to netcat's STDIN
|>>
|>> Are you trying to set up a loop of processes or something? I'm \
|>> not sure if
|>> that is even possible, although you can't rule out creative uses \
|>> of dup2()
|>> etc...
|>
|> This can't really be done with netcat, but it's quite easy to do with
|> socat; here's an example with a trivial program that reads lines from
|> its standard input and writes a single line to its standard output:
|>
|> [roam@straylight ~]$ socat -v tcp4:nimbus.fccf.net:25 exec:./heysmtp.\
|> py
...
perl(1) has IPC::Open2 for that:
use IPC::Open2;
# We use `csop' for hashing
my $MAILX = 'LC_ALL=C s-nail -#:/';
sub hash_em{
die "hash_em: open: $^E"
unless my $pid = open2 *RFD, *WFD, $MAILX;
foreach my $e (@ENTS){
print WFD "csop hash32 $e->{name}\n";
my $h = <RFD>;
chomp $h;
$e->{hash} = $h
}
print WFD "x\n";
waitpid $pid, 0;
}
hash_em()
|...but, of course, this is still not what Derek was talking about
|earlier - there is no separation of the file descriptors connected to
|the socket: closing the stdout one would not result in a FIN being sent
|along the line.
Just wanted to add earlier in the thread that on some systems
shutdown(2) equals close(2). At least it was like that on Mac OS
X (by then) Snow Leopard.
--steffen
|
|Der Kragenbaer, The moon bear,
|der holt sich munter he cheerfully and one by one
|einen nach dem anderen runter wa.ks himself off
|(By Robert Gernhardt)