D: How do I pipe (|) through three programs using std.process?
BoQsc
vaidas.boqsc at gmail.com
Sun Nov 12 13:39:25 UTC 2023
Using `spawnShell` it all seem to work.
However the question of why `spawnProcess(["find", "string to
find"]` is not working and produces error is still unresolved.
Works with `spawnShell`:
```
import std.stdio;
import std.process;
version (Windows) { enum Find = "find"; }
version (Posix) { enum Find = "grep"; }
int main (string [] args)
{
auto p1 = pipe;
auto p2 = pipe;
auto pid1 = spawnShell("echo HelloWorld", stdin, p1.writeEnd);
auto pid2 = spawnShell("find \"HelloWorld\"", p1.readEnd,
p2.writeEnd);
auto pid3 = spawnShell("find \"HelloWorld\"", p2.readEnd,
stdout);
wait (pid1);
wait (pid2);
wait (pid3);
return 0;
}
```
More information about the Digitalmars-d-learn
mailing list