develooper Front page | perl.perl6.users | Postings from July 2017

Bi-directional communication with another process

Thread Next
Norman Gaywood
July 27, 2017 23:50
Bi-directional communication with another process
Message ID:
From inside a program I'd like to send some input to the stdin of external
program and read back the stdout.

The example in under proc comes close
to what I want:

my $echo = run 'echo', 'Hello, world', :out;
my $cat  = run 'cat', '-n', :in($echo.out), :out;
say $cat.out.get;

That works, however what I want however is a single external process, sort
of like:

my $input = q:to/EOS/;
line of text
another line

my $cat  = run 'cat', '-n', :in($input.print), :out;
my $output = $cat.out.get;

say "done";
say $output;

But that is not correct. I seem to be missing something.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About