digitalmars.D.learn - Run a command-line process with data sent, and retrieve the data.
- Chris Katko (10/10) Jun 10 2022 I want to pipe in string data to a shell/commandline program,
- Chris Katko (2/12) Jun 10 2022 Okay that's probably incorrect grep, but you get the point.
- =?UTF-8?Q?Ali_=c3=87ehreli?= (3/13) Jun 10 2022 https://dlang.org/library/std/process/pipe_process.html
- =?UTF-8?Q?Ali_=c3=87ehreli?= (5/6) Jun 10 2022 I realized you may be happier with the following if all you need is stdo...
- Christopher Katko (11/18) Jun 10 2022 pipeShell works great! It even allowed me to keep the process
I want to pipe in string data to a shell/commandline program, then retrieve the output. But the documentation I read appears to only show usage for 'Files' for stdin/stdout/stderr. ala something like this: ````D string input = "hello\nworld"; string output; runProcess("grep hello", input, output); assert(output = "hello"); ````
Jun 10 2022
On Friday, 10 June 2022 at 17:37:30 UTC, Chris Katko wrote:I want to pipe in string data to a shell/commandline program, then retrieve the output. But the documentation I read appears to only show usage for 'Files' for stdin/stdout/stderr. ala something like this: ````D string input = "hello\nworld"; string output; runProcess("grep hello", input, output); assert(output = "hello"); ````Okay that's probably incorrect grep, but you get the point.
Jun 10 2022
On 6/10/22 10:37, Chris Katko wrote:I want to pipe in string data to a shell/commandline program, then retrieve the output. But the documentation I read appears to only show usage for 'Files' for stdin/stdout/stderr. ala something like this: ````D string input = "hello\nworld"; string output; runProcess("grep hello", input, output); assert(output = "hello"); ````https://dlang.org/library/std/process/pipe_process.html Ali
Jun 10 2022
On 6/10/22 10:40, Ali Çehreli wrote:https://dlang.org/library/std/process/pipe_process.htmlI realized you may be happier with the following if all you need is stdout: https://dlang.org/library/std/process/execute.html https://dlang.org/library/std/process/execute_shell.html Ali
Jun 10 2022
On Friday, 10 June 2022 at 17:49:20 UTC, Ali Çehreli wrote:On 6/10/22 10:40, Ali Çehreli wrote:pipeShell works great! It even allowed me to keep the process running "live" in a streaming mode which was going to be a later modification so I don't have to keep invoking it over and over. I'm using it at the moment, to run a prettyprinter for a console output, but one prettyprinter just straight up calls Python Pygments which can run in streaming mode and while it was surprisingly fast being called for every single line, it's certainly going to be faster without the overhead of constantly spawning a python instance. Thanks!https://dlang.org/library/std/process/pipe_process.htmlI realized you may be happier with the following if all you need is stdout: https://dlang.org/library/std/process/execute.html https://dlang.org/library/std/process/execute_shell.html Ali
Jun 10 2022