Re: pull results out of a variable

2016-09-28 Thread Brandon Allbery
On Wed, Sep 28, 2016 at 5:15 PM, Nex6 via perl6-users 
wrote:

> my $results = run 'ping', '-c', '1',$line;
>
> where $line is the IP address, $results hold the result how can i pull the
> results out? it outputs like this:
>

Actually, it doesn't have them with that invocation; they went to stdout,
which is probably your terminal. In any case, $result is a Proc object
representing the thing you ran, and will get the exit status when ping
exits.

my $proc = run 'ping', '-c', '1', $line, :out;
my $result = $proc.out.lines;

This tells `run` to capture the output with the Proc object, and you can
retrieve it with the `out` method (which returns an IO::Handle) as above.

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


pull results out of a variable

2016-09-28 Thread Nex6 via perl6-users
Hi all,

just starting my journey down Perl6, figured best way to learn it is to write 
stuff so i am do some stuff I have done in other languages. as ideas
for what to write. first a ping sweep; 

problem is:

if i:

my $results = run 'ping', '-c', '1',$line;

where $line is the IP address, $results hold the result how can i pull the 
results out? it outputs like this:

PING 4.2.2.5 (4.2.2.5): 56 data bytes
64 bytes from 4.2.2.5: icmp_seq=0 ttl=53 time=2.147 ms

--- 4.2.2.5 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 2.147/2.147/2.147/0.000 ms


Thanks in advance

-Nex6