String from executeshell

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 29 14:54:32 PDT 2015


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



More information about the Digitalmars-d-learn mailing list