Writing to stdin of a process
Craig Dillabaugh via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Apr 26 01:45:58 PDT 2014
I want to be able to write to the stdin stream of an external
process using std.process. I have the following small test app.
myecho.d
------------------------------------------------------------------
import std.stdio;
void main(string[] args)
{
foreach (line; stdin.byLine()) {
stdout.writeln(line);
}
}
------------------------------------------------------------------
If I call this from the command line, it echo's back whatever I
write
to it.
Then I have the following program.
testpipes.d
-------------------------------------------------------------------
import std.process;
import std.stdio;
void main( string[] args ) {
auto pipes = pipeProcess("./myecho", Redirect.stdin );
scope(exit) wait(pipes.pid);
pipes.stdin().writeln("Hello world");
}
--------------------------------------------------------------------
If I compile and run testpipes.d, nothing happens. I was
expecting
it to echo back "Hello world" to me.
Can anyone tell me what I am dong wrong.
More information about the Digitalmars-d-learn
mailing list