develooper Front page | perl.perl6.users | Postings from August 2018

RE: return code?

Thread Previous | Thread Next
From:
Mark Devine
Date:
August 10, 2018 02:18
Subject:
RE: return code?
Message ID:
BN6PR02MB27401034DAAA1D52586A35A5A0240@BN6PR02MB2740.namprd02.prod.outlook.com
Todd,

I cleaned up my code and published it (with the help of Patrick Spek -- thanks again).

CPAN:   https://modules.perl6.org/dist/Async::Command:cpan:MLDEVINE

I’ve been using it in an enterprise environment with 1000+ UNIX/Linux servers.  I’m able to launch hundreds of SSH commands at once and sort out each Proc::Async’s $*OUT and $*ERR without line noise.  For version 0.0.2 I hardcoded a throttle of 16 threads after graphing performance on a 4 x Linux VM – seems safe yet efficient.

Criticisms & suggestions always welcome by Perl6 mentors.

Thanks,

Mark


From: Mark Devine <mark@markdevine.com>
Sent: Saturday, July 28, 2018 16:38
To: ToddAndMargo <ToddAndMargo@zoho.com>
Cc: perl6-users <perl6-users@perl.org>
Subject: RE: return code?

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

From: Brandon Allbery <allbery.b@gmail.com<mailto:allbery.b@gmail.com>>
Sent: Saturday, July 28, 2018 16:22
To: ToddAndMargo <ToddAndMargo@zoho.com<mailto:ToddAndMargo@zoho.com>>
Cc: perl6-users <perl6-users@perl.org<mailto:perl6-users@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 <ToddAndMargo@zoho.com<mailto:ToddAndMargo@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


--
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com<mailto:allbery.b@gmail.com>                                  ballbery@sinenomine.net<mailto:ballbery@sinenomine.net>
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About