Re: D: How do I pipe (|) through three programs using std.process?

2023-11-19 Thread kdevel via Digitalmars-d-learn
On Saturday, 18 November 2023 at 18:09:53 UTC, BoQsc wrote: Latest iteration on this thread. Limitations: * pipes through two programs. * very verbose, hard to use. What exactly are you trying to achieve? ``` import std; import std.process; version (Windows) { enum Find = "find"; } version

Re: D: How do I pipe (|) through three programs using std.process?

2023-11-18 Thread BoQsc via Digitalmars-d-learn
Latest iteration on this thread. Limitations: * pipes through two programs. * very verbose, hard to use. ``` import std; import std.process; version (Windows) { enum Find = "find"; } version (Posix) { enum Find = "grep"; } void pipeTo(Pipe p, string nextprogram){ spawnShell(nextprogram

Re: D: How do I pipe (|) through three programs using std.process?

2023-11-14 Thread Jesse Phillips via Digitalmars-d-learn
On Saturday, 11 November 2023 at 17:29:14 UTC, BoQsc wrote: https://dlang.org/library/std/process.html How do I pipe (|) through three programs using std.process? https://dev.to/jessekphillips/piping-process-output-1cai Your issue with [Find, "Hello"] might be [Find, "\&quo

Re: D: How do I pipe (|) through three programs using std.process?

2023-11-12 Thread BoQsc via Digitalmars-d-learn
To make this thread more complete, here is the final version. ``` 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 HelloWorl

Re: D: How do I pipe (|) through three programs using std.process?

2023-11-12 Thread Adam D Ruppe via Digitalmars-d-learn
On Sunday, 12 November 2023 at 13:39:25 UTC, BoQsc wrote: However the question of why `spawnProcess(["find", "string to find"]` is not working and produces error is still unresolved. spawnProcess always encodes its arguments in a very specific way and the receiving programs are not always comp

Re: D: How do I pipe (|) through three programs using std.process?

2023-11-12 Thread BoQsc via Digitalmars-d-learn
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) {

Re: D: How do I pipe (|) through three programs using std.process?

2023-11-12 Thread BoQsc via Digitalmars-d-learn
On Windows: While trying to use `spawnshell` I discovered that I can not use any alphabetical letters inside the `spawnProcess([Find, "Hello"])` it all works when they are numerical `[Find, "6515"]`. As of recent testing `[Find, "df123"]` also is acceptable, but not when letter is on the righ

Re: D: How do I pipe (|) through three programs using std.process?

2023-11-11 Thread kdevel via Digitalmars-d-learn
On Saturday, 11 November 2023 at 17:29:14 UTC, BoQsc wrote: https://dlang.org/library/std/process.html How do I pipe (|) through three programs using std.process? ``` echo This is a sample text | find "sample" | find "text" ``` ```d import std.stdio; import std.proces

Re: running a command in a directory using std.process

2013-10-24 Thread Benjamin Thaut
Am 24.10.2013 19:03, schrieb Timothee Cour: +1 this is a command use case. Further,relying on shell such as cd subdir && foo is fragile: if it fails, we're not sure whether it's because it couldn't cd to subdir or because of foo. Woudl the following be as efficient? system_in_dir(string dir, st

Re: running a command in a directory using std.process

2013-10-24 Thread Timothee Cour
+1 this is a command use case. Further,relying on shell such as cd subdir && foo is fragile: if it fails, we're not sure whether it's because it couldn't cd to subdir or because of foo. Woudl the following be as efficient? system_in_dir(string dir, string action){ auto path=getcwd scope(exit) c

Re: running a command in a directory using std.process

2013-10-24 Thread Benjamin Thaut
Am 24.10.2013 09:06, schrieb simendsjo: On Thursday, 24 October 2013 at 06:25:40 UTC, Benjamin Thaut wrote: As far as I can tell std.process can only run commands in the working directory of the currently executing function. I want to execute a certain program inside a subdirectory on windows an

Re: running a command in a directory using std.process

2013-10-24 Thread simendsjo
On Thursday, 24 October 2013 at 06:25:40 UTC, Benjamin Thaut wrote: As far as I can tell std.process can only run commands in the working directory of the currently executing function. I want to execute a certain program inside a subdirectory on windows and can't get it to work: myproject |-

running a command in a directory using std.process

2013-10-23 Thread Benjamin Thaut
As far as I can tell std.process can only run commands in the working directory of the currently executing function. I want to execute a certain program inside a subdirectory on windows and can't get it to work: myproject |- subdir So my executable has "myproject" as working directory. And I

Re: using std.process

2010-06-12 Thread Philippe Sigaud
Graham > Try giving an absolute path to 'mkdir'. I'm fairly sure that the exec* >> family does not use the PATH environment. >> > > I tried the different versions and used execvp precisely because it's supposed to provide the path. But I admit I never tried giving it an entire path. BCS: > That

Re: using std.process

2010-06-11 Thread BCS
Hello Graham, On Fri, 11 Jun 2010 19:09:04 +, Philippe Sigaud wrote: OK, this is a real newbie question: How can I use std.process? when I do: import std.process; void main() { execvp("mkdir", ["test"]); } nothing happens. What am I doing wrong? I'm on Vista there, didn't try the equi

Re: using std.process

2010-06-11 Thread Graham Fawcett
On Fri, 11 Jun 2010 19:09:04 +, Philippe Sigaud wrote: > OK, this is a real newbie question: > > How can I use std.process? > > when I do: > > import std.process; > > void main() { > execvp("mkdir", ["test"]); > } > > nothing happens. > > What am I doing wrong? > I'm on Vista there,

using std.process

2010-06-11 Thread Philippe Sigaud
OK, this is a real newbie question: How can I use std.process? when I do: import std.process; void main() { execvp("mkdir", ["test"]); } nothing happens. What am I doing wrong? I'm on Vista there, didn't try the equivalent under Linux. Philippe