www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - String from executeshell

reply "William Dunne" <william mimex.net> writes:
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?
Apr 29 2015
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
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
Apr 29 2015
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
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
Apr 29 2015
next sibling parent "Adam D. Ruppe" <destructionator gmail.com> writes:
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
Apr 29 2015
prev sibling parent "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
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").
Apr 29 2015