On 02/17/2017 06:38 PM, ToddAndMargo wrote:
Hi All,
rakudo-star-0.0.2016.11-1.el7.x86_64 (Linux)
Two questions about substitutes for system calls:
1) Is there a reliably Perl 6 way to copy things to the
clipboard? (Perl 5 has a module, but it is unreliable
and I have to make a system call.)
To answer my own questions to help others,
https://github.com/kmwallio/p6-OS-Clipboard
is the module for it.
But ... it calls xclip (Linux), pbcopy (OS X), or clip (Windows),
so you might as well call these programs directly with qx or qqx
rather than having to use Panda to compile the module
For instance, under Perl 5 (sorry no Perl 6 example yet):
system ( "cat $TmpFile | xclip -selection clipboard" );
2) Is there a way to get a list of running processes similar
to "ps ax"?
Just call "ps" directly with qx or qqx. For instance:
my @ps = qx ( ps ax ).lines;
use qqx if you are using a variable inside the argument.
For instance:
my @Result = qqx ( systemctl restart $Service ).lines;
Many thanks,
-T
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~