*From:* Brandon Allbery <allber...@gmail.com>
*Sent:* Saturday, July 28, 2018 16:22
*To:* ToddAndMargo <toddandma...@zoho.com>
*Cc:* perl6-users <perl6-us...@perl.org>
*Subject:* Re: return code?

Yes, that's what I was addressing: you can tell run() to do that, keeping stderr separate with :err(). qxx does that internally.

On Sat, Jul 28, 2018 at 4:12 PM ToddAndMargo <toddandma...@zoho.com <mailto:toddandma...@zoho.com>> wrote:

    On 07/28/2018 12:56 PM, Brandon Allbery wrote:
     > You can control where run() sends things.

    Hi Brandon,

    I adore the run command.

    In this particular instance (curl's progress meter, which is
    written to STDERR), I want STDERR to write to the shell, but
    want to collect STDIN and the return code.

         curl xxxx; echo $?

    will send both to STDIN, which I can easily deal with.

    -T


On 07/28/2018 01:38 PM, Mark Devine wrote:
Todd,

I see that you’re frequently running commands in your code like me.  I was looking for a reliable reusable approach for commands for a long time.  I’m still learning & not quite ready to step up to contribute to the ecosystem yet (https://docs.perl6.org/language/modules.html). After reading Perl 6 Fundamentals (Moritz Lenz), I cobbled together a reusable Command.pm6 for myself based on his examples.  Method ‘run’ for a single async command, or methods ‘sow’+‘reap’ for multiple async (possibly all different) commands, with all returns collected in Command::Result objects.

https://github.com/markldevine/perl6-Command

Now whenever I need any general-purpose external command, I ‘use Command;’ and it has never failed me (I.e. curl, , ssh, etc.).

Because it’s not in the ecosystem, git clone it into a directory and set PERL6LIB=</dir/ > or ‘use lib </dir/>’ internally.  Docs are internal POD.

If any of the Perl 6 big brains are reading this and would provide some welcome criticism resulting in something that should be published, I would upload as per the instructions it or hand it off to someone more capable of maintaining it.

If you give it a try, I think that you might find it helpful.

Thanks,

Mark


Hi Mark,

I will give it a look!

I wrote my own "RunNoShell" and "RunNoShellErr".  The later returns
the STDERR.  And I address both as a string, "rather" "than" "as"
"chunks", "which" "I" "find" "clunky".

I will post it to vpaste if you want to take a look.

-T

Reply via email to