Thread overview | ||||||
---|---|---|---|---|---|---|
|
December 10, 2020 CMD && comand not work | ||||
---|---|---|---|---|
| ||||
In this very generic example && not work to finalize the instruct and start a new instruct. Yes, I know dmd can build and run without it, but this is only a example. execute(["cmd", "/c", "dmd test.d", "&&", "start test.exe"]); How can I substitute && ? |
December 10, 2020 Re: CMD && comand not work | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marcone | On Thursday, 10 December 2020 at 21:01:30 UTC, Marcone wrote: > In this very generic example && not work to finalize the instruct and start a new instruct. Yes, I know dmd can build and run without it, but this is only a example. > > execute(["cmd", "/c", "dmd test.d", "&&", "start test.exe"]); > > How can I substitute && ? `&&` is a feature of the shell, so you need to use `executeShell`. Doc: http://phobos.dpldocs.info/std.process.executeShell.html |
December 10, 2020 Re: CMD && comand not work | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marcone | On Thursday, 10 December 2020 at 21:01:30 UTC, Marcone wrote:
> In this very generic example && not work to finalize the instruct and start a new instruct. Yes, I know dmd can build and run without it, but this is only a example.
>
> execute(["cmd", "/c", "dmd test.d", "&&", "start test.exe"]);
>
> How can I substitute && ?
You can use executeShell() as mentioned already or do something like this:
auto p = execute(["dmd", "test.d"]);
if(p.status == 0) {
execute(["test.exe"]);
}
|
December 11, 2020 Re: CMD && comand not work | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marcone | On Thursday, 10 December 2020 at 21:01:30 UTC, Marcone wrote:
> In this very generic example && not work to finalize the instruct and start a new instruct. Yes, I know dmd can build and run without it, but this is only a example.
>
> execute(["cmd", "/c", "dmd test.d", "&&", "start test.exe"]);
>
> How can I substitute && ?
Try other variants:
execute(["cmd", "/c", "dmd test.d && start test.exe"]);
execute(["cmd", "/c", "dmd", "test.d", "&&", "start", "test.exe"]);
|
Copyright © 1999-2021 by the D Language Foundation