I am attempting to learn IPC::Run so that I may implement some privilege separation between daemons for generic operations and specific things that require root.
My child is not returning anything to the parent, apparently because it's not reading from the parent via "while (<STDIN>) {}". How would I get the child to read what the parent sends? My example is below.
The "cat1" is from perldoc IPC::Run, and runs as expected when using cat as the child (I get back on stdout what I used for input). When I use my "wr2" script as the child I get nothing on the parent's stdout. When I use "wr2" separately on the command line I get what I expect:
$ echo 123123 | wr2 123123
I've googled at great length, but all the examples are about being the parent, not being the child.
This is cat1:
#!/usr/bin/perl use warnings; use strict; use IPC::Run qw(start pump finish timeout); #my @cat = qw(/bin/cat); my @cat = qw(/home/cwood/bin/wr2); my ($in, $out, $err); my $h = start \@cat, \$in, \$out, \$err, timeout(10); $in .= "some input\n"; pump $h until $out =~ /input\n/g; $in .= "some more input\n"; pump $h until $out =~ /\G.*more input\n/; $in .= "some final input\n"; finish $h or die "cat returned $?"; warn $err if $err; print $out; ## All of cat's output
This is wr2:
#!/usr/bin/perl use warnings; use strict; while (<STDIN>) { print; }
In reply to How to be a child of IPC::Run? by cwood
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |