digitalmars.D.learn - executeShell doesn't work but system does
- Smoke (4/4) Jun 26 2016 system("cls") works but executeShell doesn't. system is
- ag0aep6g (32/35) Jun 26 2016 `system` directly prints its output, `executeShell` returns it in a
- Steven Schveighoffer (10/18) Jun 27 2016 Use spawn-related function, and avoid capturing output instead. Not sure...
- Smoke (3/12) Jun 27 2016 neither work but
- Satoshi (3/7) Jun 26 2016 I have problem with executeShell on windows 10 (LDC 1.0.0) too.
system("cls") works but executeShell doesn't. system is depreciated. What's going on? The docs say that it creates a new process. I simply want to clear the console!
Jun 26 2016
On 06/26/2016 05:37 PM, Smoke Adams wrote:system("cls") works but executeShell doesn't. system is depreciated.Unsolicited spelling correction: no 'i' in "deprecated".What's going on? The docs say that it creates a new process. I simply want to clear the console!`system` directly prints its output, `executeShell` returns it in a tuple with the status code. Maybe cls works by printing some specific clear code. If so, you have to print the output of the command. This works with `clear` on Linux which seems to behave similarly to Windows' cls: ---- void main() { import std.stdio: write, writeln; import std.process: executeShell; import std.exception: enforce; writeln("A"); auto r = executeShell("clear"); enforce(r.status == 0); write(r.output); writeln("B"); } ---- `wait(spawnShell(...))` is the other suggestion from `system`'s deprecation message. It works for `clear`, too: ---- void main() { import std.stdio: writeln; import std.process: spawnShell, wait; writeln("A"); wait(spawnShell("clear")); writeln("B"); } ----
Jun 26 2016
On 6/26/16 12:02 PM, ag0aep6g wrote:On 06/26/2016 05:37 PM, Smoke Adams wrote:Use spawn-related function, and avoid capturing output instead. Not sure if you need to call spawnShell (which creates a new system shell to execute the command), it depends on whether cls is a shell builtin or an executable.system("cls") works but executeShell doesn't. system is depreciated.Unsolicited spelling correction: no 'i' in "deprecated".Perhaps not exactly correct, but close enough. When you call "executeShell", the subprocess is started with stdout/err sent to a pipe, and no console is passed to the subprocess. Probably cls sees it's not talking to a console and exits. -SteveWhat's going on? The docs say that it creates a new process. I simply want to clear the console!`system` directly prints its output, `executeShell` returns it in a tuple with the status code. Maybe cls works by printing some specific clear code. If so, you have to print the output of the command.
Jun 27 2016
On Sunday, 26 June 2016 at 16:02:18 UTC, ag0aep6g wrote:On 06/26/2016 05:37 PM, Smoke Adams wrote:neither work but wait(spawnShell("cls"));[...]Unsolicited spelling correction: no 'i' in "deprecated".[...]`system` directly prints its output, `executeShell` returns it in a tuple with the status code. Maybe cls works by printing some specific clear code. If so, you have to print the output of the command. [...]
Jun 27 2016
On Sunday, 26 June 2016 at 15:37:03 UTC, "Smoke" Adams wrote:system("cls") works but executeShell doesn't. system is depreciated. What's going on? The docs say that it creates a new process. I simply want to clear the console!I have problem with executeShell on windows 10 (LDC 1.0.0) too. When I rewrote it into http://prntscr.com/blc9j8 it works.
Jun 26 2016
On Sunday, 26 June 2016 at 17:56:08 UTC, Satoshi wrote:On Sunday, 26 June 2016 at 15:37:03 UTC, "Smoke" Adams wrote:OT but please, refrain from using screenshots. I know it's very customary on windows but I can't copy paste code from a screenshot to play with it and manually copying is error-prone. We manipulate text, let's stay with it.system("cls") works but executeShell doesn't. system is depreciated. What's going on? The docs say that it creates a new process. I simply want to clear the console!I have problem with executeShell on windows 10 (LDC 1.0.0) too. When I rewrote it into http://prntscr.com/blc9j8 it works.
Jun 26 2016
On Sunday, 26 June 2016 at 19:01:07 UTC, cym13 wrote:On Sunday, 26 June 2016 at 17:56:08 UTC, Satoshi wrote:Sorry... It's same function as executeImpl just with changed byChunk to 1. It corrupt stack when I called the original function. https://github.com/ldc-developers/phobos/blob/aa133b5927bbc5f9669374d5bb0f206f6f68cfe4/std/process.d#L2130On Sunday, 26 June 2016 at 15:37:03 UTC, "Smoke" Adams wrote:OT but please, refrain from using screenshots. I know it's very customary on windows but I can't copy paste code from a screenshot to play with it and manually copying is error-prone. We manipulate text, let's stay with it.system("cls") works but executeShell doesn't. system is depreciated. What's going on? The docs say that it creates a new process. I simply want to clear the console!I have problem with executeShell on windows 10 (LDC 1.0.0) too. When I rewrote it into http://prntscr.com/blc9j8 it works.
Jun 27 2016