Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
April 29, 2015 String from executeshell | ||||
---|---|---|---|---|
| ||||
I'm trying to run this command: wget -O - URL | gpg -d and get the result of the action, but I can't quite work out to do it. currently it looks like: executeShell(escapeShellCommand("wget", "-O", "-", url, "|", "gpg", "-D")); But I can't work out how to pull the string returned with this. Any help? |
April 29, 2015 Re: String from executeshell | ||||
---|---|---|---|---|
| ||||
Posted in reply to William Dunne | On 04/29/2015 02:05 PM, William Dunne wrote: > I'm trying to run this command: > > wget -O - URL | gpg -d and get the result of the action, but I can't > quite work out to do it. > > currently it looks like: > > executeShell(escapeShellCommand("wget", "-O", "-", url, "|", "gpg", "-D")); > > But I can't work out how to pull the string returned with this. > > Any help? executeShell returns the status and the output as a type (perhaps a tuple? :) ): http://dlang.org/phobos/std_process.html#.executeShell You use the return value for both the status and the output: auto wget = executeShell(escapeShellCommand(/* ... */)); if (wget.status == 0) { /* success */ writeln(wget.output); // <-- HERE } Ali |
April 29, 2015 Re: String from executeshell | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On 04/29/2015 02:54 PM, Ali Çehreli wrote:
> executeShell returns the status and the output as a type
Certainly not. The output is an object of a special type, which the documentation refers to as 'auto'. Grrr... :) Ok, maybe it's a Voldemort type. Anyway...
Ali
|
April 29, 2015 Re: String from executeshell | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Wednesday, 29 April 2015 at 21:56:18 UTC, Ali Çehreli wrote:
> Certainly not. The output is an object of a special type, which the documentation refers to as 'auto'. Grrr... :) Ok, maybe it's a Voldemort type. Anyway...
That's idiotic, to be frank, it should just be a traditional struct declared outside.
"Just because we can do a thing, it does not necessarily follow that we must do that thing" -- from the Gospel of Kirk
|
April 30, 2015 Re: String from executeshell | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Wednesday, 29 April 2015 at 21:56:18 UTC, Ali Çehreli wrote: > On 04/29/2015 02:54 PM, Ali Çehreli wrote: > >> executeShell returns the status and the output as a type > > Certainly not. The output is an object of a special type, which the documentation refers to as 'auto'. Grrr... :) Ok, maybe it's a Voldemort type. Anyway... The function's documentation has a "Returns" section, which says: > Returns: > An std.typecons.Tuple!(int, "status", string, "output"). |
Copyright © 1999-2021 by the D Language Foundation