Pipe one shell command into another

2016-01-30 Thread Andrew via Digitalmars-d-learn
Hi, I'd like to run a shell command which involves piping one thing into another and then processes the output line by line, i.e. something like "ls -l | sort -k5,5n" What I've come up so far with is: import std.process; import std.stdio; void main(){ auto pipesLs = pipeProcess(["ls", "-l

Re: Pipe one shell command into another

2016-01-30 Thread Griffon26 via Digitalmars-d-learn
On Saturday, 30 January 2016 at 15:12:26 UTC, Andrew wrote: foreach(line; pipesLs.stdout.byLine) pipesSort.stdin.writeln(line); Because you write sort's input first and read its output later, it might end up blocking if ls generates too much data. The output pipe of sort will fill up, c

Re: Pipe one shell command into another

2016-01-30 Thread Andrew via Digitalmars-d-learn
On Saturday, 30 January 2016 at 15:57:49 UTC, Griffon26 wrote: On Saturday, 30 January 2016 at 15:12:26 UTC, Andrew wrote: foreach(line; pipesLs.stdout.byLine) pipesSort.stdin.writeln(line); Because you write sort's input first and read its output later, it might end up blocking if ls g